diff options
author | Neil <nyamatongwe@gmail.com> | 2020-01-25 08:34:03 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2020-01-25 08:34:03 +1100 |
commit | ee79a4e2a10c3f75fc8e24f875e0304fafdcab2b (patch) | |
tree | 3e82902208874ae8b19619f96886ade4561a64da | |
parent | e1ec844eb03e5c0de240e426762b87d21213a5ac (diff) | |
download | scintilla-mirror-ee79a4e2a10c3f75fc8e24f875e0304fafdcab2b.tar.gz |
Bug [#2152]. Ignore Alt+Keypad keys that will result in a WM_CHAR.
-rw-r--r-- | doc/ScintillaDoc.html | 6 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 6 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 33 |
3 files changed, 43 insertions, 2 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 4ad921cf5..ec1e79afb 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -5549,6 +5549,12 @@ struct Sci_TextToFind { If you are building a table, you might want to use <code>SCMOD_NORM</code>, which has the value 0, to mean no modifiers.</p> + <p>On Win32, the numeric keypad with Alt pressed can be used to enter characters by number. + This can produce unexpected results in non-numlock mode when function keys are assigned so + potentially problematic keys are ignored. For example, setting + <code>SCMOD_ALT</code>,<code>SCK_UP</code> will only be active for the Up key on the + main cursor keys, not the numeric keypad.</p> + <p><b id="SCI_ASSIGNCMDKEY">SCI_ASSIGNCMDKEY(int <a class="jump" href="#keyDefinition">keyDefinition</a>, int sciCommand)</b><br /> This assigns the given key definition to a Scintilla command identified by diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 4ed002f36..7ca70eeff 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -571,6 +571,12 @@ Fix drag and drop between different encodings by always providing CF_UNICODETEXT only. <a href="https://sourceforge.net/p/scintilla/bugs/2151/">Bug #2151</a>. </li> + <li> + On Win32, the numeric keypad with Alt pressed can be used to enter characters by number. + This can produce unexpected results in non-numlock mode when function keys are assigned. + Potentially problematic keys like Alt+KeypadUp are now ignored. + <a href="https://sourceforge.net/p/scintilla/bugs/2152/">Bug #2152</a>. + </li> </ul> <h3> <a href="https://www.scintilla.org/scite430.zip">Release 4.3.0</a> diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index a2e59687d..4ed03c787 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -169,6 +169,30 @@ bool KeyboardIsKeyDown(int key) noexcept { return (::GetKeyState(key) & 0x80000000) != 0; } +constexpr bool KeyboardIsNumericKeypadFunction(uptr_t wParam, sptr_t lParam) { + // Bit 24 is the extended keyboard flag and the numeric keypad is non-extended + if ((lParam & (1 << 24)) != 0) { + // Not from the numeric keypad + return false; + } + + switch (wParam) { + case VK_INSERT: // 0 + case VK_END: // 1 + case VK_DOWN: // 2 + case VK_NEXT: // 3 + case VK_LEFT: // 4 + case VK_CLEAR: // 5 + case VK_RIGHT: // 6 + case VK_HOME: // 7 + case VK_UP: // 8 + case VK_PRIOR: // 9 + return true; + default: + return false; + } +} + } class ScintillaWin; // Forward declaration for COM interface subobjects @@ -1551,16 +1575,21 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case WM_KEYDOWN: { // Platform::DebugPrintf("Keydown %c %c%c%c%c %x %x\n", // iMessage == WM_KEYDOWN ? 'K' : 'S', - // (lParam & 1 << 24) ? '-' : 'E', + // (lParam & (1 << 24)) ? 'E' : '-', // KeyboardIsKeyDown(VK_SHIFT) ? 'S' : '-', // KeyboardIsKeyDown(VK_CONTROL) ? 'C' : '-', // KeyboardIsKeyDown(VK_MENU) ? 'A' : '-', // wParam, lParam); lastKeyDownConsumed = false; + const bool altDown = KeyboardIsKeyDown(VK_MENU); + if (altDown && KeyboardIsNumericKeypadFunction(wParam, lParam)) { + // Don't interpret these as they may be characters entered by number. + return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); + } const int ret = KeyDownWithModifiers(KeyTranslate(static_cast<int>(wParam)), ModifierFlags(KeyboardIsKeyDown(VK_SHIFT), KeyboardIsKeyDown(VK_CONTROL), - KeyboardIsKeyDown(VK_MENU)), + altDown), &lastKeyDownConsumed); if (!ret && !lastKeyDownConsumed) { return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); |