mirror of
https://github.com/textmate/textmate.git
synced 2026-01-22 21:27:56 -05:00
Strip the numeric keypad flag for key events
This means pressing e.g. ⌘/ (using the slash on the numeric keypad) will still work to toggle comments. It also means that we can no longer bind specifically to the numeric keypad keys, but I don’t think anyone actually does that (given that few have numeric keypads). The ideal solution would be to first do a literal check and then, if there was no match and the key event had the numeric keypad flag set, do a test with this flag removed, but that would change the simple string compare we presently use plus the easy caching and binary search of finding the item that matches a key event, i.e. it would add complexity to the code with no known argument in favor of this flexibility.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
PUBLIC std::string to_s (NSString* aString);
|
||||
PUBLIC std::string to_s (NSData* aString);
|
||||
PUBLIC std::string to_s (NSEvent* anEvent);
|
||||
PUBLIC std::string to_s (NSEvent* anEvent, bool preserveNumPadFlag = false);
|
||||
|
||||
namespace ns
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ static bool is_ascii (std::string const& str)
|
||||
end if
|
||||
*/
|
||||
|
||||
std::string to_s (NSEvent* anEvent)
|
||||
std::string to_s (NSEvent* anEvent, bool preserveNumPadFlag)
|
||||
{
|
||||
CGEventRef cgEvent = [anEvent CGEvent];
|
||||
CGKeyCode key = (CGKeyCode)[anEvent keyCode];
|
||||
@@ -81,7 +81,7 @@ std::string to_s (NSEvent* anEvent)
|
||||
if(flags & kCGEventFlagMaskNumericPad)
|
||||
{
|
||||
static std::string const numPadKeys = "0123456789=/*-+.,";
|
||||
if(numPadKeys.find(keyStringNoFlags) != std::string::npos)
|
||||
if(preserveNumPadFlag && numPadKeys.find(keyStringNoFlags) != std::string::npos)
|
||||
newFlags |= kCGEventFlagMaskNumericPad;
|
||||
flags &= ~kCGEventFlagMaskControl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user