fix numpad keys on win32
This commit is contained in:
parent
d83804f2cb
commit
aafe219532
|
@ -117,7 +117,6 @@ function Terminal.init()
|
||||||
Hotkeys.bindKeyDown('Down', function() navigateCommand(-1) end, commandLineEdit)
|
Hotkeys.bindKeyDown('Down', function() navigateCommand(-1) end, commandLineEdit)
|
||||||
Hotkeys.bindKeyDown('Tab', completeCommand, commandLineEdit)
|
Hotkeys.bindKeyDown('Tab', completeCommand, commandLineEdit)
|
||||||
Hotkeys.bindKeyDown('Enter', doCommand, commandLineEdit)
|
Hotkeys.bindKeyDown('Enter', doCommand, commandLineEdit)
|
||||||
Hotkeys.bindKeyDown('Return', doCommand, commandLineEdit)
|
|
||||||
|
|
||||||
terminalBuffer = terminalWidget:getChildById('terminalBuffer')
|
terminalBuffer = terminalWidget:getChildById('terminalBuffer')
|
||||||
Logger.setOnLog(onLog)
|
Logger.setOnLog(onLog)
|
||||||
|
|
|
@ -63,7 +63,6 @@ KeyUnknown = 0
|
||||||
KeyEscape = 1
|
KeyEscape = 1
|
||||||
KeyTab = 2
|
KeyTab = 2
|
||||||
KeyBackspace = 3
|
KeyBackspace = 3
|
||||||
KeyReturn = 4
|
|
||||||
KeyEnter = 5
|
KeyEnter = 5
|
||||||
KeyInsert = 6
|
KeyInsert = 6
|
||||||
KeyDelete = 7
|
KeyDelete = 7
|
||||||
|
@ -183,7 +182,6 @@ KeyCodeDescs = {
|
||||||
[KeyEscape] = 'Escape',
|
[KeyEscape] = 'Escape',
|
||||||
[KeyTab] = 'Tab',
|
[KeyTab] = 'Tab',
|
||||||
[KeyBackspace] = 'Backspace',
|
[KeyBackspace] = 'Backspace',
|
||||||
[KeyReturn] = 'Return',
|
|
||||||
[KeyEnter] = 'Enter',
|
[KeyEnter] = 'Enter',
|
||||||
[KeyInsert] = 'Insert',
|
[KeyInsert] = 'Insert',
|
||||||
[KeyDelete] = 'Delete',
|
[KeyDelete] = 'Delete',
|
||||||
|
|
|
@ -9,7 +9,7 @@ end
|
||||||
function UIWindow:onKeyPress(keyCode, keyboardModifiers, wouldFilter)
|
function UIWindow:onKeyPress(keyCode, keyboardModifiers, wouldFilter)
|
||||||
if wouldFilter then return end
|
if wouldFilter then return end
|
||||||
if keyboardModifiers == KeyboardNoModifier then
|
if keyboardModifiers == KeyboardNoModifier then
|
||||||
if keyCode == KeyReturn or keyCode == KeyEnter then
|
if keyCode == KeyEnter then
|
||||||
signalcall(self.onEnter, self)
|
signalcall(self.onEnter, self)
|
||||||
elseif keyCode == KeyEscape then
|
elseif keyCode == KeyEscape then
|
||||||
signalcall(self.onEscape, self)
|
signalcall(self.onEscape, self)
|
||||||
|
|
|
@ -93,7 +93,6 @@ function Console.create()
|
||||||
Hotkeys.bindKeyDown('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
|
Hotkeys.bindKeyDown('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
|
Hotkeys.bindKeyDown('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Enter', Console.sendCurrentMessage, consolePanel)
|
Hotkeys.bindKeyDown('Enter', Console.sendCurrentMessage, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Return', Console.sendCurrentMessage, consolePanel)
|
|
||||||
|
|
||||||
-- apply buttom functions after loaded
|
-- apply buttom functions after loaded
|
||||||
connect(consolePanel:getChildById('nextChannelButton'), { onClick = function() consoleTabBar:selectNextTab() end } )
|
connect(consolePanel:getChildById('nextChannelButton'), { onClick = function() consoleTabBar:selectNextTab() end } )
|
||||||
|
|
|
@ -60,7 +60,6 @@ namespace Fw
|
||||||
KeyEscape = 1,
|
KeyEscape = 1,
|
||||||
KeyTab = 2,
|
KeyTab = 2,
|
||||||
KeyBackspace = 3,
|
KeyBackspace = 3,
|
||||||
KeyReturn = 4,
|
|
||||||
KeyEnter = 5,
|
KeyEnter = 5,
|
||||||
KeyInsert = 6,
|
KeyInsert = 6,
|
||||||
KeyDelete = 7,
|
KeyDelete = 7,
|
||||||
|
|
|
@ -41,7 +41,7 @@ WIN32Window::WIN32Window()
|
||||||
|
|
||||||
m_keyMap[VK_ESCAPE] = Fw::KeyEscape;
|
m_keyMap[VK_ESCAPE] = Fw::KeyEscape;
|
||||||
m_keyMap[VK_TAB] = Fw::KeyTab;
|
m_keyMap[VK_TAB] = Fw::KeyTab;
|
||||||
m_keyMap[VK_RETURN] = Fw::KeyReturn;
|
m_keyMap[VK_RETURN] = Fw::KeyEnter;
|
||||||
m_keyMap[VK_BACK] = Fw::KeyBackspace;
|
m_keyMap[VK_BACK] = Fw::KeyBackspace;
|
||||||
m_keyMap[VK_SPACE] = Fw::KeySpace;
|
m_keyMap[VK_SPACE] = Fw::KeySpace;
|
||||||
|
|
||||||
|
@ -162,7 +162,6 @@ WIN32Window::WIN32Window()
|
||||||
m_keyMap[VK_DECIMAL] = Fw::KeyPeriod;
|
m_keyMap[VK_DECIMAL] = Fw::KeyPeriod;
|
||||||
m_keyMap[VK_DIVIDE] = Fw::KeySlash;
|
m_keyMap[VK_DIVIDE] = Fw::KeySlash;
|
||||||
m_keyMap[VK_MULTIPLY] = Fw::KeyAsterisk;
|
m_keyMap[VK_MULTIPLY] = Fw::KeyAsterisk;
|
||||||
m_keyMap[VK_SEPARATOR] = Fw::KeyEnter;
|
|
||||||
|
|
||||||
// keypad with numlock off
|
// keypad with numlock off
|
||||||
m_keyMap[VK_NUMPAD0] = Fw::KeyNumpad0;
|
m_keyMap[VK_NUMPAD0] = Fw::KeyNumpad0;
|
||||||
|
@ -423,6 +422,51 @@ void WIN32Window::poll()
|
||||||
updateUnmaximizedCoords();
|
updateUnmaximizedCoords();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fw::Key WIN32Window::retranslateVirtualKey(WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if(!(((HIWORD(lParam) >> 8) & 0xFF) & 1)) {
|
||||||
|
// ignore numpad keys when numlock is on
|
||||||
|
if((wParam >= VK_NUMPAD0 && wParam <= VK_NUMPAD9) || wParam == VK_SEPARATOR)
|
||||||
|
return Fw::KeyUnknown;
|
||||||
|
|
||||||
|
// retranslate numpad keys
|
||||||
|
switch(wParam) {
|
||||||
|
case VK_INSERT:
|
||||||
|
wParam = VK_NUMPAD0;
|
||||||
|
break;
|
||||||
|
case VK_END:
|
||||||
|
wParam = VK_NUMPAD1;
|
||||||
|
break;
|
||||||
|
case VK_DOWN:
|
||||||
|
wParam = VK_NUMPAD2;
|
||||||
|
break;
|
||||||
|
case VK_NEXT:
|
||||||
|
wParam = VK_NUMPAD3;
|
||||||
|
break;
|
||||||
|
case VK_LEFT:
|
||||||
|
wParam = VK_NUMPAD4;
|
||||||
|
break;
|
||||||
|
case VK_CLEAR:
|
||||||
|
wParam = VK_NUMPAD5;
|
||||||
|
break;
|
||||||
|
case VK_RIGHT:
|
||||||
|
wParam = VK_NUMPAD6;
|
||||||
|
break;
|
||||||
|
case VK_HOME:
|
||||||
|
wParam = VK_NUMPAD7;
|
||||||
|
break;
|
||||||
|
case VK_UP:
|
||||||
|
wParam = VK_NUMPAD8;
|
||||||
|
break;
|
||||||
|
case VK_PRIOR:
|
||||||
|
wParam = VK_NUMPAD9;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_keyMap[wParam];
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
|
@ -452,11 +496,11 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_KEYDOWN: {
|
case WM_KEYDOWN: {
|
||||||
processKeyDown(m_keyMap[wParam]);
|
processKeyDown(retranslateVirtualKey(wParam, lParam));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_KEYUP: {
|
case WM_KEYUP: {
|
||||||
processKeyUp(m_keyMap[wParam]);
|
processKeyUp(retranslateVirtualKey(wParam, lParam));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_LBUTTONDOWN: {
|
case WM_LBUTTONDOWN: {
|
||||||
|
@ -641,7 +685,6 @@ void WIN32Window::setTitle(const std::string& title)
|
||||||
|
|
||||||
void WIN32Window::setMinimumSize(const Size& minimumSize)
|
void WIN32Window::setMinimumSize(const Size& minimumSize)
|
||||||
{
|
{
|
||||||
dump << "set minimum";
|
|
||||||
m_minimumSize = minimumSize;
|
m_minimumSize = minimumSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,3 +813,4 @@ std::string WIN32Window::getPlatformType()
|
||||||
{
|
{
|
||||||
return "WIN32-WGL";
|
return "WIN32-WGL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ class WIN32Window : public PlatformWindow
|
||||||
LRESULT windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
LRESULT windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
friend class WindowProcProxy;
|
friend class WindowProcProxy;
|
||||||
|
|
||||||
|
Fw::Key retranslateVirtualKey(WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WIN32Window();
|
WIN32Window();
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ X11Window::X11Window()
|
||||||
|
|
||||||
m_keyMap[XK_Escape] = Fw::KeyEscape;
|
m_keyMap[XK_Escape] = Fw::KeyEscape;
|
||||||
m_keyMap[XK_Tab] = Fw::KeyTab;
|
m_keyMap[XK_Tab] = Fw::KeyTab;
|
||||||
m_keyMap[XK_Return] = Fw::KeyReturn;
|
m_keyMap[XK_Return] = Fw::KeyEnter;
|
||||||
m_keyMap[XK_BackSpace] = Fw::KeyBackspace;
|
m_keyMap[XK_BackSpace] = Fw::KeyBackspace;
|
||||||
|
|
||||||
m_keyMap[XK_Page_Up] = Fw::KeyPageUp;
|
m_keyMap[XK_Page_Up] = Fw::KeyPageUp;
|
||||||
|
|
Loading…
Reference in New Issue