mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-03 04:52:54 +00:00
Bug 946044 Handle context menu key of PC keyboard on Mac r=smichaud
This commit is contained in:
parent
90f7caa453
commit
d7fcc64c1e
@ -325,6 +325,7 @@ const MAC_VK_PC_ScrollLock = 0x6A;
|
||||
const MAC_VK_F14 = 0x6B;
|
||||
const MAC_VK_PC_Pause = 0x6B;
|
||||
const MAC_VK_F10 = 0x6D;
|
||||
const MAC_VK_PC_ContextMenu = 0x6E;
|
||||
const MAC_VK_F12 = 0x6F;
|
||||
const MAC_VK_F15 = 0x71;
|
||||
const MAC_VK_Help = 0x72;
|
||||
|
@ -37,6 +37,8 @@ enum
|
||||
kVK_PC_Backspace = kVK_Delete,
|
||||
kVK_PC_Delete = kVK_ForwardDelete,
|
||||
|
||||
kVK_PC_ContextMenu = 0x6E,
|
||||
|
||||
kVK_Powerbook_KeypadEnter = 0x34 // Enter on Powerbook's keyboard is different
|
||||
};
|
||||
|
||||
|
@ -142,6 +142,7 @@ GetKeyNameForNativeKeyCode(unsigned short aNativeKeyCode)
|
||||
case kVK_RightArrow: return "RightArrow";
|
||||
case kVK_UpArrow: return "UpArrow";
|
||||
case kVK_DownArrow: return "DownArrow";
|
||||
case kVK_PC_ContextMenu: return "ContextMenu";
|
||||
|
||||
case kVK_Function: return "Function";
|
||||
case kVK_VolumeUp: return "VolumeUp";
|
||||
@ -339,6 +340,12 @@ GetWindowLevelName(NSInteger aWindowLevel)
|
||||
|
||||
#endif // #ifdef PR_LOGGING
|
||||
|
||||
static bool
|
||||
IsControlChar(uint32_t aCharCode)
|
||||
{
|
||||
return aCharCode < ' ' || aCharCode == 0x7F;
|
||||
}
|
||||
|
||||
static uint32_t gHandlerInstanceCount = 0;
|
||||
static TISInputSourceWrapper gCurrentInputSource;
|
||||
|
||||
@ -884,6 +891,13 @@ TISInputSourceWrapper::InitKeyEvent(NSEvent *aNativeKeyEvent,
|
||||
}
|
||||
}
|
||||
|
||||
// Remove control characters which shouldn't be inputted on editor.
|
||||
// XXX Currently, we don't find any cases inserting control characters with
|
||||
// printable character. So, just checking first character is enough.
|
||||
if (!insertString.IsEmpty() && IsControlChar(insertString[0])) {
|
||||
insertString.Truncate();
|
||||
}
|
||||
|
||||
aKeyEvent.keyCode =
|
||||
ComputeGeckoKeyCode(nativeKeyCode, kbType, aKeyEvent.IsMeta());
|
||||
|
||||
@ -943,6 +957,8 @@ TISInputSourceWrapper::InitKeyEvent(NSEvent *aNativeKeyEvent,
|
||||
InitKeyPressEvent(aNativeKeyEvent,
|
||||
insertString.IsEmpty() ? 0 : insertString[0],
|
||||
aKeyEvent, kbType);
|
||||
MOZ_ASSERT(!aKeyEvent.charCode || !IsControlChar(aKeyEvent.charCode),
|
||||
"charCode must not be a control character");
|
||||
} else {
|
||||
aKeyEvent.charCode = 0;
|
||||
aKeyEvent.isChar = false; // XXX not used in XP level
|
||||
@ -1256,6 +1272,8 @@ TISInputSourceWrapper::ComputeGeckoKeyCode(UInt32 aNativeKeyCode,
|
||||
case kVK_UpArrow: return NS_VK_UP;
|
||||
case kVK_DownArrow: return NS_VK_DOWN;
|
||||
|
||||
case kVK_PC_ContextMenu: return NS_VK_CONTEXT_MENU;
|
||||
|
||||
case kVK_ANSI_1: return NS_VK_1;
|
||||
case kVK_ANSI_2: return NS_VK_2;
|
||||
case kVK_ANSI_3: return NS_VK_3;
|
||||
@ -1467,6 +1485,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
|
||||
}
|
||||
|
||||
// If this is the context menu key command, send a context menu key event.
|
||||
// XXX Should we dispatch context menu event at pressing kVK_PC_ContextMenu?
|
||||
NSUInteger modifierFlags =
|
||||
[aNativeEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask;
|
||||
if (modifierFlags == NSControlKeyMask &&
|
||||
@ -4444,6 +4463,7 @@ TextInputHandlerBase::IsSpecialGeckoKey(UInt32 aNativeKeyCode)
|
||||
case kVK_PC_Delete:
|
||||
case kVK_Tab:
|
||||
case kVK_PC_Backspace:
|
||||
case kVK_PC_ContextMenu:
|
||||
|
||||
case kVK_JIS_Eisu:
|
||||
case kVK_JIS_Kana:
|
||||
|
@ -412,6 +412,7 @@ KEY_MAP_ANDROID (Info, AKEYCODE_INFO)
|
||||
|
||||
// Menu
|
||||
KEY_MAP_WIN (Menu, VK_APPS)
|
||||
KEY_MAP_COCOA (Menu, kVK_PC_ContextMenu)
|
||||
KEY_MAP_GTK (Menu, GDK_Menu)
|
||||
KEY_MAP_QT (Menu, Qt::Key_Menu)
|
||||
KEY_MAP_ANDROID (Menu, AKEYCODE_MENU)
|
||||
|
@ -533,6 +533,8 @@ function runKeyEventTests()
|
||||
nsIDOMKeyEvent.DOM_VK_DELETE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||
testKey({layout:"US", keyCode:MAC_VK_PC_Pause, chars:"\uF711", unmodifiedChars:"\uF711"},
|
||||
nsIDOMKeyEvent.DOM_VK_SCROLL_LOCK, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||
testKey({layout:"US", keyCode:MAC_VK_PC_ContextMenu, chars:"\u0010", unmodifiedChars:"\u0010"},
|
||||
nsIDOMKeyEvent.DOM_VK_CONTEXT_MENU, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||
|
||||
testKey({layout:"US", keyCode:MAC_VK_F1, function:1, chars:"\uF704", unmodifiedChars:"\uF704"},
|
||||
nsIDOMKeyEvent.DOM_VK_F1, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||
|
Loading…
x
Reference in New Issue
Block a user