Menu

#1867 [macOS] add, subtract and divide codes are not converted to scintilla key codes

Bug
closed-fixed
5
2016-10-16
2016-09-27
Tse Kit Yam
No

I find that we have used SCK_ADD, SCK_SUBTRACTand SCK_DIVIDE in mac short key, however, none of add key, substract key nor divide key are converted to these SCK_ values. As a result, none of them works.

This patch convert translate these macOS key codes to Scintilla's

1 Attachments

Discussion

  • Tse Kit Yam

    Tse Kit Yam - 2016-09-27

    I find that we have used SCK_ADD, SCK_SUBTRACT and SCK_DIVIDE in mac shortcut map, however, none of add key, substract key nor divide key are converted to these SCK_ values. As a result, none of them works.
    This patch converts translate these macOS key codes to Scintilla's

    changelog: fix English mistakes
    P.S. seems that I can edit a comment but not the ticket itself.

     

    Last edit: Tse Kit Yam 2016-09-27
  • Neil Hodgson

    Neil Hodgson - 2016-09-27

    SCK_ADD, SCK_SUBTRACT and SCK_DIVIDE refer to the keypad keys. They are based on Win32's VK_ADD, VK_SUBTRACT, and VK_DIVIDE. The patch appears to be for the ASCII '+', '-' and '/' and won't match keypad keys.

    http://www.kbdedit.com/manual/low_level_vk_list.html

     
  • Tse Kit Yam

    Tse Kit Yam - 2016-09-28

    No matter we are press the + next to the delete key or the + on the numpad, both returns + in [input characterAtIndex: i]. So we can't use the character to identify which + key is pressed.

    If we want to identifier which + key is down, we have to use another NSEvent property named keyCode, which returns virtual key code value, kEventParamKeyCode, assoicated to the key down event. These values are defined in Carbon framework. e.g. the + key on numpad return kVK_ANSI_KeypadPlus and the + key next to delete key returns kVK_ANSI_Equal (because it is a = key basically).

    As a reusIt, I want to modify bool ScintillaCocoa::KeyboardInput(NSEvent* event), such that it will translate keyCode to constants used by sintilla, instead of characters charactersIgnoringModifiers. The down side is that we have to translate all the keyCode to ASCII, or scintila key code value.

    Any comment?

     

    Last edit: Tse Kit Yam 2016-09-28
  • Tse Kit Yam

    Tse Kit Yam - 2016-09-28

    By the way, there is a easier way, static inline UniChar KeyTranslate(UniChar unicodeChar) not only need a Unichar, and also the kEventParamKeyCode from [event keyCode]. Then we can have somthing like

    case '+': {
        if (keyCode == kVK_ANSI_KeypadPlus)
              return SCK_ADD;
         else
             return unicodeChar;
    
     

    Last edit: Tse Kit Yam 2016-09-28
  • Neil Hodgson

    Neil Hodgson - 2016-09-28

    With Cocoa there is a NSNumericPadKeyMask that should be included in modifierFlags.

     
  • Tse Kit Yam

    Tse Kit Yam - 2016-09-29

    I don't know defining a new modifier flags for the numpad mask is a good idea or not, so I added NSEventModifierFlags to KeyTranslate as an additional parameter instead.

     
    • Neil Hodgson

      Neil Hodgson - 2016-09-29

      That behaves OK for me. Are they all the keys you want to handle this way?

       
      • Tse Kit Yam

        Tse Kit Yam - 2016-09-30

        Yes, there should be not other keys need such handling.

         
  • Neil Hodgson

    Neil Hodgson - 2016-09-30
    • labels: --> scintilla, cocoa, keyboard
    • status: open --> open-fixed
    • assigned_to: Neil Hodgson
     
  • Neil Hodgson

    Neil Hodgson - 2016-09-30

    Committed fix as [3e90b7].

     

    Related

    Commit: [3e90b7]

  • Neil Hodgson

    Neil Hodgson - 2016-10-16
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.