Richard
Topic Author
Posts: 6
Joined: 13 Jul 2019, 15:24

Re: KeyDown KeyUp for symbols

06 Aug 2019, 14:28

By modified codes below, it works for more symbols, but the some keys (arrows, space, backspace etc) going through the mKeyDown that don't go to the event handler OnkeyDown

add code block in Src/Packages/App/XDisplay/Src/XDisplay.cpp
       case XK_exclam: return Key_OemExclam;
        case XK_quotedbl: return Key_OemQuotes;
        case XK_numbersign: return Key_OemNumberSign;
        case XK_dollar: return Key_OemDollar;
        case XK_percent: return Key_OemPercent;
        case XK_ampersand: return Key_OemAmpersand;
        case XK_apostrophe: return Key_OemApostrophe;
        case XK_parenleft: return Key_OemOpenParen;
        case XK_parenright: return Key_OemCloseParen;
        case XK_asterisk: return Key_OemAsterisk;
        case XK_plus: return Key_OemPlus;
        case XK_comma: return Key_OemComma;
        case XK_minus: return Key_OemMinus;
        case XK_period: return Key_OemPeriod;
        case XK_slash: return Key_OemSlash;
        case XK_colon: return Key_OemColon;
        case XK_semicolon: return Key_OemSemicolon;
        case XK_less: return Key_OemLess;
        case XK_equal: return Key_OemEqual;
        case XK_greater: return Key_OemGreater;
        case XK_question: return Key_OemQuestion;
        case XK_at: return Key_OemAt;
        case XK_bracketleft: return Key_OemOpenBrackets;
        case XK_backslash: return Key_OemBackslash;
        case XK_bracketright: return Key_OemCloseBrackets;
        case XK_asciicircum: return Key_OemAsciicircum;
        case XK_underscore: return Key_OemUnderscore;
        case XK_grave: return Key_OemGrave;
        case XK_braceleft: return Key_OemOpenBrace;
        case XK_bar: return Key_OemPipe;
        case XK_braceright: return Key_OemCloseBrace;
        case XK_asciitilde: return Key_OemTilde;
        case XK_nobreakspace: return Key_OemNoBreakSpace;

replace code block in Src/Packages/App/XDisplay/Src/XDisplay.cpp
      
                case KeyPress:
                {
                    char text[256];
                    XKeyEvent* e = (XKeyEvent*)&event;
                    KeySym ksym;
                    int keys = XLookupString(e, text, sizeof(text) - 1, &ksym, NULL);
                    if (keys == 0)
                    ksym = XLookupKeysym(e, 0);

                    Key k = NoesisKey(ksym);
                    if (k != Key_None)
                    {
                        NS_LOG_TRACE("KEYDOWN: %s", XKeysymToString(ksym));
                        mKeyDown(this, k);
                    }

                    if (_xic != 0)
                    {
                        Status status;
                        char text[256];
                        int size = Xutf8LookupString(_xic, e, text, sizeof(text) - 1, 0, &status);
                        if (size > 0 && (status == XLookupChars || status == XLookupBoth))
                        {
                            text[size] = 0;
                            NS_LOG_TRACE("TEXT: %s", text);

                            const char* text_ = text;
                            uint32_t c;
                            while ((c = UTF8::Next(text_)) != 0)
                            {
                                mChar(this, c);
                            }
                        }
                    }

                    break;
                }
                case KeyRelease:
                {
                    char text[256];
                    XKeyEvent* e = (XKeyEvent*)&event;
                    KeySym ksym;
                    int keys = XLookupString(e, text, sizeof(text) - 1, &ksym, NULL);
                    if (keys == 0)
                    ksym = XLookupKeysym(e, 0);

                    Key k = NoesisKey(ksym);
                    if (k != Key_None)
                    {
                      NS_LOG_TRACE("KEYUP: %s", XKeysymToString(ksym));
                      mKeyUp(this, k);
                    }
                    break;
                }

 
add code block in NsGui/InputEnums.h
  
    Key_Oem8,
    Key_OemEqual = Key_Oem8,
    Key_Oem9,
    Key_OemExclam = Key_Oem9,
    Key_Oem10,
    Key_OemNumberSign = Key_Oem10,
    Key_Oem11,
    Key_OemDollar = Key_Oem11,
    Key_Oem12,
    Key_OemPercent = Key_Oem12,
    Key_Oem13,
    Key_OemAmpersand = Key_Oem13,
    Key_Oem14,
    Key_OemApostrophe = Key_Oem14,
    Key_Oem15,
    Key_OemOpenParen = Key_Oem15,
    Key_Oem16,
    Key_OemCloseParen = Key_Oem16,
    Key_Oem17,
    Key_OemAsterisk = Key_Oem17,
    Key_Oem18,
    Key_OemSlash = Key_Oem18,
    Key_Oem19,
    Key_OemColon = Key_Oem19,
    Key_Oem20,
    Key_OemLess = Key_Oem20,
    Key_Oem21,
    Key_OemGreater = Key_Oem21,
    Key_Oem22,
    Key_OemAt = Key_Oem22,
    Key_Oem23,
    Key_OemAsciicircum = Key_Oem23,
    Key_Oem24,
    Key_OemUnderscore = Key_Oem24,
    Key_Oem25,
    Key_OemGrave = Key_Oem25,
    Key_Oem26,
    Key_OemOpenBrace = Key_Oem26,
    Key_Oem27,
    Key_OemCloseBrace = Key_Oem27,
    Key_Oem28,
    Key_OemNoBreakSpace = Key_Oem28,

Tags:

Who is online

Users browsing this forum: niklasvh, unvestigate and 7 guests