diff options
| author | Neil <nyamatongwe@gmail.com> | 2013-08-15 15:13:15 +1000 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2013-08-15 15:13:15 +1000 |
| commit | d396f66bf0bc8d4c777c744efe77ccb5b28b385f (patch) | |
| tree | 9dc0a355f751c37c953e835ac04a5dee383d6f51 /cocoa | |
| parent | c68e1a5ffc74569e4d406e3c904f010390577fcf (diff) | |
| download | scintilla-mirror-d396f66bf0bc8d4c777c744efe77ccb5b28b385f.tar.gz | |
Feature: [feature-requests:#1007]. Option to allow mouse selection to
switch to rectangular by pressing Alt after start of gesture.
From Neomi.
Diffstat (limited to 'cocoa')
| -rw-r--r-- | cocoa/ScintillaCocoa.mm | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 34e016d94..5c378c903 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -1838,6 +1838,24 @@ static inline UniChar KeyTranslate(UniChar unicodeChar) //-------------------------------------------------------------------------------------------------- /** + * Translate NSEvent modifier flags into SCI_* modifier flags. + * + * @param modifiers An integer bit set of NSSEvent modifier flags. + * @return A set of SCI_* modifier flags. + */ +static int TranslateModifierFlags(NSUInteger modifiers) +{ + // Signal Control as SCI_META + return + (((modifiers & NSShiftKeyMask) != 0) ? SCI_SHIFT : 0) | + (((modifiers & NSCommandKeyMask) != 0) ? SCI_CTRL : 0) | + (((modifiers & NSAlternateKeyMask) != 0) ? SCI_ALT : 0) | + (((modifiers & NSControlKeyMask) != 0) ? SCI_META : 0); +} + +//-------------------------------------------------------------------------------------------------- + +/** * Main keyboard input handling method. It is called for any key down event, including function keys, * numeric keypad input and whatnot. * @@ -1847,15 +1865,8 @@ static inline UniChar KeyTranslate(UniChar unicodeChar) bool ScintillaCocoa::KeyboardInput(NSEvent* event) { // For now filter out function keys. - NSUInteger modifiers = [event modifierFlags]; - NSString* input = [event characters]; - bool control = (modifiers & NSControlKeyMask) != 0; - bool shift = (modifiers & NSShiftKeyMask) != 0; - bool command = (modifiers & NSCommandKeyMask) != 0; - bool alt = (modifiers & NSAlternateKeyMask) != 0; - bool handled = false; // Handle each entry individually. Usually we only have one entry anway. @@ -1866,13 +1877,7 @@ bool ScintillaCocoa::KeyboardInput(NSEvent* event) bool consumed = false; // Consumed as command? - // Signal Control as SCMOD_META - int modifierKeys = - (shift ? SCI_SHIFT : 0) | - (command ? SCI_CTRL : 0) | - (alt ? SCI_ALT : 0) | - (control ? SCI_META : 0); - if (KeyDownWithModifiers(key, modifierKeys, &consumed)) + if (KeyDownWithModifiers(key, TranslateModifierFlags([event modifierFlags]), &consumed)) handled = true; if (consumed) handled = true; @@ -1977,7 +1982,7 @@ void ScintillaCocoa::MouseMove(NSEvent* event) { lastMouseEvent = event; - ButtonMove(ConvertPoint([event locationInWindow])); + ButtonMoveWithModifiers(ConvertPoint([event locationInWindow]), TranslateModifierFlags([event modifierFlags])); } //-------------------------------------------------------------------------------------------------- |
