mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Fix some special keys, specifically backspace (it was mismapped to delete)
This commit is contained in:
parent
267e02c3d3
commit
4166327919
@ -80,7 +80,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
NSImage *load_image(const Filename &filename);
|
NSImage *load_image(const Filename &filename);
|
||||||
|
|
||||||
ButtonHandle map_function_key(unsigned short keycode);
|
ButtonHandle map_key(unsigned short keycode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NSWindow *_window;
|
NSWindow *_window;
|
||||||
|
@ -1555,30 +1555,23 @@ handle_key_event(NSEvent *event) {
|
|||||||
nassertv([str length] == 1);
|
nassertv([str length] == 1);
|
||||||
unichar c = [str characterAtIndex: 0];
|
unichar c = [str characterAtIndex: 0];
|
||||||
|
|
||||||
ButtonHandle button;
|
ButtonHandle button = map_key(c);
|
||||||
|
|
||||||
if (c >= 0xF700 && c < 0xF900) {
|
if (c < 0xF700 || c >= 0xF900) {
|
||||||
// Special function keys.
|
// If a down event and not a special function key,
|
||||||
button = map_function_key(c);
|
// process it as keystroke as well.
|
||||||
|
|
||||||
} else if (c == 0x3) {
|
|
||||||
button = KeyboardButton::enter();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// If a down event, process as keystroke too.
|
|
||||||
if ([event type] == NSKeyDown) {
|
if ([event type] == NSKeyDown) {
|
||||||
NSString *origstr = [event characters];
|
NSString *origstr = [event characters];
|
||||||
c = [str characterAtIndex: 0];
|
c = [str characterAtIndex: 0];
|
||||||
_input_devices[0].keystroke(c);
|
_input_devices[0].keystroke(c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (button == ButtonHandle::none()) {
|
||||||
// That done, continue trying to find out the button handle.
|
// That done, continue trying to find out the button handle.
|
||||||
if ([str canBeConvertedToEncoding: NSASCIIStringEncoding]) {
|
if ([str canBeConvertedToEncoding: NSASCIIStringEncoding]) {
|
||||||
// Nhm, ascii character perhaps?
|
// Nhm, ascii character perhaps?
|
||||||
button = KeyboardButton::ascii_key([str cStringUsingEncoding: NSASCIIStringEncoding]);
|
button = KeyboardButton::ascii_key([str cStringUsingEncoding: NSASCIIStringEncoding]);
|
||||||
|
|
||||||
} else {
|
|
||||||
button = ButtonHandle::none();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1694,13 +1687,24 @@ handle_wheel_event(double x, double y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: CocoaGraphicsWindow::map_function_key
|
// Function: CocoaGraphicsWindow::map_key
|
||||||
// Access: Private
|
// Access: Private
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
ButtonHandle CocoaGraphicsWindow::
|
ButtonHandle CocoaGraphicsWindow::
|
||||||
map_function_key(unsigned short keycode) {
|
map_key(unsigned short keycode) {
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
|
case NSEnterCharacter:
|
||||||
|
return KeyboardButton::enter();
|
||||||
|
case NSBackspaceCharacter:
|
||||||
|
case NSDeleteCharacter:
|
||||||
|
// NSDeleteCharacter fires when I press backspace.
|
||||||
|
return KeyboardButton::backspace();
|
||||||
|
case NSTabCharacter:
|
||||||
|
case NSBackTabCharacter:
|
||||||
|
// BackTabCharacter is sent when shift-tab is used.
|
||||||
|
return KeyboardButton::tab();
|
||||||
|
|
||||||
case NSUpArrowFunctionKey:
|
case NSUpArrowFunctionKey:
|
||||||
return KeyboardButton::up();
|
return KeyboardButton::up();
|
||||||
case NSDownArrowFunctionKey:
|
case NSDownArrowFunctionKey:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user