Skip to content

Commit

Permalink
Implemented the CinderView::flagsChanged method so a Cinder app will …
Browse files Browse the repository at this point in the history
…handle keyDown and keyUp events for modifer keys.

Also added the META keys to the KeyEvent key table.
  • Loading branch information
calebjohnston authored and andrewfb committed Mar 5, 2013
1 parent a28c3a0 commit a9a5473
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/cinder/app/CinderView.mm
Expand Up @@ -279,16 +279,19 @@ - (void)keyUp:(NSEvent*)theEvent
[mDelegate keyUp:&keyEvent];
}

// TODO: this isn't implemented yet
- (void)flagsChanged:(NSEvent*)theEvent
{
/* char c = 0;
int code = [theEvent keyCode];
int mods = [self prepKeyEventModifiers:theEvent];
NSLog( @"%@", theEvent );
cinder::app::KeyEvent keyEvent = cinder::app::KeyEvent (cinder::app::KeyEvent::translateNativeKeyCode( code ), (char)c, mods, code);
[mDelegate keyDown:&keyEvent];*/
int code = [theEvent keyCode];
int mods = [self prepKeyEventModifiers:theEvent];

if (mods == 0) {
cinder::app::KeyEvent keyEvent( [mDelegate getWindowRef], cinder::app::KeyEvent::translateNativeKeyCode( code ), 0, 0, mods, code);
[mDelegate keyUp:&keyEvent];
}
else {
cinder::app::KeyEvent keyEvent( [mDelegate getWindowRef], cinder::app::KeyEvent::translateNativeKeyCode( code ), 0, 0, mods, code);
[mDelegate keyDown:&keyEvent];
}
}

- (void)mouseDown:(NSEvent*)theEvent
Expand Down
2 changes: 2 additions & 0 deletions src/cinder/app/KeyEvent.cpp
Expand Up @@ -155,6 +155,8 @@ static void initKeyTable()
sKeyTable[0x3B] = KeyEvent::KEY_LCTRL;
sKeyTable[0x3D] = KeyEvent::KEY_RALT;
sKeyTable[0x3A] = KeyEvent::KEY_LALT;
sKeyTable[0x37] = KeyEvent::KEY_LMETA;
sKeyTable[0x36] = KeyEvent::KEY_RMETA;
// sKeyTable[VK_RWIN] = KeyEvent::KEY_RSUPER;
// sKeyTable[VK_LWIN] = KeyEvent::KEY_LSUPER;

Expand Down

0 comments on commit a9a5473

Please sign in to comment.