mirror of https://github.com/buggins/dlangui.git
fix keypad behavior under SDL2 when NumLock is on - for dlangide#172
This commit is contained in:
parent
63c1513c4e
commit
0665ea504f
|
|
@ -796,10 +796,19 @@ class SDLWindow : Window {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isNumLockEnabled()
|
||||||
|
{
|
||||||
|
version(Windows) {
|
||||||
|
return !!(GetKeyState( VK_NUMLOCK ) & 1);
|
||||||
|
} else {
|
||||||
|
return !!(SDL_GetModState() & KMOD_NUM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint _keyFlags;
|
uint _keyFlags;
|
||||||
bool processKeyEvent(KeyAction action, uint keyCode, uint flags) {
|
bool processKeyEvent(KeyAction action, uint keyCodeIn, uint flags) {
|
||||||
debug(DebugSDL) Log.d("processKeyEvent ", action, " SDL key=0x", format("%08x", keyCode), " SDL flags=0x", format("%08x", flags));
|
debug(DebugSDL) Log.d("processKeyEvent ", action, " SDL key=0x", format("%08x", keyCodeIn), " SDL flags=0x", format("%08x", flags));
|
||||||
keyCode = convertKeyCode(keyCode);
|
uint keyCode = convertKeyCode(keyCodeIn);
|
||||||
flags = convertKeyFlags(flags);
|
flags = convertKeyFlags(flags);
|
||||||
if (action == KeyAction.KeyDown) {
|
if (action == KeyAction.KeyDown) {
|
||||||
switch(keyCode) {
|
switch(keyCode) {
|
||||||
|
|
@ -842,6 +851,13 @@ class SDLWindow : Window {
|
||||||
_keyFlags = flags;
|
_keyFlags = flags;
|
||||||
|
|
||||||
debug(DebugSDL) Log.d("processKeyEvent ", action, " converted key=0x", format("%08x", keyCode), " converted flags=0x", format("%08x", flags));
|
debug(DebugSDL) Log.d("processKeyEvent ", action, " converted key=0x", format("%08x", keyCode), " converted flags=0x", format("%08x", flags));
|
||||||
|
if (action == KeyAction.KeyDown || action == KeyAction.KeyUp) {
|
||||||
|
if ((keyCodeIn >= SDLK_KP_1 && keyCodeIn <= SDLK_KP_0
|
||||||
|
|| keyCodeIn == SDLK_KP_PERIOD
|
||||||
|
//|| keyCodeIn >= 0x40000059 && keyCodeIn
|
||||||
|
) && isNumLockEnabled)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
bool res = dispatchKeyEvent(new KeyEvent(action, keyCode, flags));
|
bool res = dispatchKeyEvent(new KeyEvent(action, keyCode, flags));
|
||||||
// if ((keyCode & 0x10000) && (keyCode & 0xF000) != 0xF000) {
|
// if ((keyCode & 0x10000) && (keyCode & 0xF000) != 0xF000) {
|
||||||
// dchar[1] text;
|
// dchar[1] text;
|
||||||
|
|
|
||||||
|
|
@ -1688,7 +1688,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
cancelHoverTimer();
|
cancelHoverTimer();
|
||||||
bool ctrlOrAltPressed = false; //(event.flags & (KeyFlag.Control /* | KeyFlag.Alt */));
|
bool ctrlOrAltPressed = false; //(event.flags & (KeyFlag.Control /* | KeyFlag.Alt */));
|
||||||
if (event.action == KeyAction.Text && event.text.length && !ctrlOrAltPressed) {
|
if (event.action == KeyAction.Text && event.text.length && !ctrlOrAltPressed) {
|
||||||
Log.d("text entered: ", event.text);
|
//Log.d("text entered: ", event.text);
|
||||||
if (readOnly)
|
if (readOnly)
|
||||||
return true;
|
return true;
|
||||||
if (replaceMode && _selectionRange.empty && _content[_caretPos.line].length >= _caretPos.pos + event.text.length) {
|
if (replaceMode && _selectionRange.empty && _content[_caretPos.line].length >= _caretPos.pos + event.text.length) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue