KeyPad Enter Key doesn't work like Enter Key


#1

Hi,

This is my first post and i’m a French guy, so sorry for my bad english …
On Linux, the KeyPad Enter Key doesn’t work like Enter Key

So my patch to fix-it:

File: ./modules/juce_gui_basics/native/juce_linux_Windowing.cpp

void handleKeyPressEvent (XKeyEvent& keyEvent)

  •            case XK_KP_Enter:       keyCode = XK_Return; break;
    
  •            case XK_KP_Enter:       keyCode = XK_Return; keyPressed = true; keyCode &= 0xff; break;

#2

When using Introjucer, normal Enter(Return) does not work (for example when enetring additional library names), and in the same field Backspace does not work, in both cases the cursor does not move anywhere.


#3

Hi Jules,
I corrected the problem in the KeyPad code.

File: ./modules/juce_gui_basics/native/juce_linux_Windowing.cpp
Function: void handleKeyPressEvent (XKeyEvent& keyEvent)

        if ((sym & 0xff00) == 0xff00)
        {
            switch (sym)  // Translate keypad
            {
                case XK_KP_Divide:      keyCode = XK_slash; break;
                case XK_KP_Multiply:    keyCode = XK_asterisk; break;
                case XK_KP_Subtract:    keyCode = XK_hyphen; break;
                case XK_KP_Add:         keyCode = XK_plus; break;
                case XK_KP_Enter:       keyCode = XK_Return; break;

                case XK_KP_0:           keyCode = XK_0; break;
                case XK_KP_1:           keyCode = XK_1; break;
                case XK_KP_2:           keyCode = XK_2; break;
                case XK_KP_3:           keyCode = XK_3; break;
                case XK_KP_4:           keyCode = XK_4; break;
                case XK_KP_5:           keyCode = XK_5; break;
                case XK_KP_6:           keyCode = XK_6; break;
                case XK_KP_7:           keyCode = XK_7; break;
                case XK_KP_8:           keyCode = XK_8; break;
                case XK_KP_9:           keyCode = XK_9; break;

                case XK_KP_Insert:      keyCode = XK_Insert; break;
                case XK_KP_Delete:      keyCode = XK_Delete; break;
                case XK_KP_End:         keyCode = XK_End; break;
                case XK_KP_Down:        keyCode = XK_Down; break;
                case XK_KP_Page_Down:   keyCode = XK_Page_Down; break;
                case XK_KP_Left:        keyCode = XK_Left; break;
                case XK_KP_Right:       keyCode = XK_Right; break;
                case XK_KP_Home:        keyCode = XK_Home; break;
                case XK_KP_Up:          keyCode = XK_Up; break;
                case XK_KP_Page_Up:     keyCode = XK_Page_Up; break;

                default:                break;
            }

            switch (keyCode)
            {
                case XK_Left:
                case XK_Right:
                case XK_Up:
                case XK_Down:
                case XK_Page_Up:
                case XK_Page_Down:
                case XK_End:
                case XK_Home:
                case XK_Delete:
                case XK_Insert:
                    keyPressed = true;
                    keyCode = (keyCode & 0xff) | Keys::extendedKeyModifier;
                    break;

                case XK_Tab:
                case XK_Return:
                case XK_Escape:
                case XK_BackSpace:
                    keyPressed = true;
                    keyCode &= 0xff;
                    break;

                default:
                    if (sym >= XK_F1 && sym <= XK_F16)
                    {
                        keyPressed = true;
                        keyCode = (sym & 0xff) | Keys::extendedKeyModifier;
                    }
                    break;
            }
        }

F.


#4

Cool - much appreciated, I’ll take a look at that asap!


#5

Hi Jules,

The del key (not on the keypad) doesn’t work now :frowning:
So you can adjust this with my edit (between each set of /********************/ comments) :

File: ./modules/juce_gui_basics/native/juce_linux_Windowing.cpp
Function: void handleKeyPressEvent (XKeyEvent& keyEvent)
Line: 1412

            switch (sym)  // Translate keypad
            {
                case XK_KP_Add:         keyCode = XK_plus; break;
                case XK_KP_Subtract:    keyCode = XK_hyphen; break;
                case XK_KP_Divide:      keyCode = XK_slash; break;
                case XK_KP_Multiply:    keyCode = XK_asterisk; break;
                case XK_KP_Enter:       keyCode = XK_Return; break;
                case XK_KP_Insert:      keyCode = XK_Insert; break;
/********************/
                case XK_Delete:
/*******************/
                case XK_KP_Delete:      keyCode = XK_Delete; break;
                case XK_KP_Left:        keyCode = XK_Left; break;
                case XK_KP_Right:       keyCode = XK_Right; break;
                case XK_KP_Up:          keyCode = XK_Up; break;
                case XK_KP_Down:        keyCode = XK_Down; break;
                case XK_KP_Home:        keyCode = XK_Home; break;
                case XK_KP_End:         keyCode = XK_End; break;
                case XK_KP_Page_Down:   keyCode = XK_Page_Down; break;
                case XK_KP_Page_Up:     keyCode = XK_Page_Up; break;

                case XK_KP_0:           keyCode = XK_0; break;
                case XK_KP_1:           keyCode = XK_1; break;
                case XK_KP_2:           keyCode = XK_2; break;
                case XK_KP_3:           keyCode = XK_3; break;
                case XK_KP_4:           keyCode = XK_4; break;
                case XK_KP_5:           keyCode = XK_5; break;
                case XK_KP_6:           keyCode = XK_6; break;
                case XK_KP_7:           keyCode = XK_7; break;
                case XK_KP_8:           keyCode = XK_8; break;
                case XK_KP_9:           keyCode = XK_9; break;

                default:                break;
            }

F.


#6

Ok, will do, thanks!