diff --git a/modules/client_entergame/characterlist.lua b/modules/client_entergame/characterlist.lua index 8ff72dc2..7704659e 100644 --- a/modules/client_entergame/characterlist.lua +++ b/modules/client_entergame/characterlist.lua @@ -8,10 +8,10 @@ local characterList -- private functions local function onCharactersWindowKeyPress(self, keyCode, keyText, keyboardModifiers) if keyboardModifiers == KeyboardNoModifier then - if keyCode == KeyUp or keyCode == KeyTab then + if keyCode == KeyUp then characterList:focusPreviousChild(ActiveFocusReason) return true - elseif keyCode == KeyDown then + elseif keyCode == KeyDown or keyCode == KeyTab then characterList:focusNextChild(ActiveFocusReason) return true end diff --git a/modules/core_lib/hotkeys.lua b/modules/core_lib/hotkeys.lua index 0dd285d4..4780c8eb 100644 --- a/modules/core_lib/hotkeys.lua +++ b/modules/core_lib/hotkeys.lua @@ -29,7 +29,7 @@ end local function determineKeyComboDesc(keyCode, keyboardModifiers) local keyCombo = {} - if keyCode == KeyShift or keyCode == KeyAlt or keyCode == KeyAltGr then + if keyCode == KeyCtrl or keyCode == KeyShift or keyCode == KeyAlt or keyCode == KeyAltGr then table.insert(keyCombo, keyCode) elseif KeyCodeDescs[keyCode] ~= nil then if keyboardModifiers == KeyboardCtrlModifier then @@ -59,6 +59,7 @@ local function determineKeyComboDesc(keyCode, keyboardModifiers) end local function onWidgetKeyPress(widget, keyCode, keyText, keyboardModifiers) + if keyCode == KeyUnknown then return end local keyComboDesc = determineKeyComboDesc(keyCode, keyboardModifiers) local callback = widget.boundKeyCombos[keyComboDesc] if callback then diff --git a/modules/core_styles/styles/panels.otui b/modules/core_styles/styles/panels.otui index d631697b..7631b54b 100644 --- a/modules/core_styles/styles/panels.otui +++ b/modules/core_styles/styles/panels.otui @@ -16,7 +16,6 @@ InterfacePanel < Panel image-border: 4 InterfacePanel2 < Panel - focusable: false image-source: /core_styles/images/interface_panel2.png image-border: 4 diff --git a/modules/core_widgets/uitabbar.lua b/modules/core_widgets/uitabbar.lua index eba0cfe3..26e4b5c9 100644 --- a/modules/core_widgets/uitabbar.lua +++ b/modules/core_widgets/uitabbar.lua @@ -14,6 +14,7 @@ end -- public functions function UITabBar.create() local tabbar = UITabBar.internalCreate() + tabbar:setFocusable(false) tabbar.tabs = {} return tabbar end @@ -46,6 +47,7 @@ function UITabBar:addTab(text, panel) end function UITabBar:selectTab(tabButton) + if self.currentTabButton == tabButton then return end if self.contentWidget then local selectedWidget = self.contentWidget:getFirstChild() if selectedWidget then @@ -55,13 +57,31 @@ function UITabBar:selectTab(tabButton) tabButton.tabPanel:fill('parent') end - tabButton:setChecked(true) - tabButton:setOn(false) - tabButton.blinking = false if self.currentTabButton then self.currentTabButton:setChecked(false) end self.currentTabButton = tabButton + tabButton:setChecked(true) + tabButton:setOn(false) + tabButton.blinking = false +end + +function UITabBar:selectNextTab() + if self.currentTabButton == nil then return end + local index = table.find(self.tabs, self.currentTabButton) + if index == nil then return end + local nextTab = self.tabs[index + 1] or self.tabs[1] + if not nextTab then return end + self:selectTab(nextTab) +end + +function UITabBar:selectPrevTab() + if self.currentTabButton == nil then return end + local index = table.find(self.tabs, self.currentTabButton) + if index == nil then return end + local prevTab = self.tabs[index - 1] or self.tabs[#self.tabs] + if not prevTab then return end + self:selectTab(prevTab) end function UITabBar:blinkTab(tabButton) diff --git a/modules/game/game.lua b/modules/game/game.lua index 72f4cd3c..8727e86f 100644 --- a/modules/game/game.lua +++ b/modules/game/game.lua @@ -18,9 +18,9 @@ function Game.createInterface() CharacterList.destroyLoadBox() Game.gameUi = displayUI('game.otui') rootWidget:moveChildToIndex(Game.gameUi, 1) - Game.gameMapPanel = Game.gameUi:getChildById('mapPanel') - Game.gameRightPanel = Game.gameUi:getChildById('rightPanel') - Game.gameBottomPanel = Game.gameUi:getChildById('bottomPanel') + Game.gameMapPanel = Game.gameUi:getChildById('gameMapPanel') + Game.gameRightPanel = Game.gameUi:getChildById('gameRightPanel') + Game.gameBottomPanel = Game.gameUi:getChildById('gameBottomPanel') Game.gameUi.onKeyPress = onGameKeyPress end diff --git a/modules/game/game.otui b/modules/game/game.otui index d9212757..9f445ac9 100644 --- a/modules/game/game.otui +++ b/modules/game/game.otui @@ -4,7 +4,7 @@ UIGame anchors.top: topMenu.bottom InterfacePanel - id: rightPanel + id: gameRightPanel width: 200 layout: verticalBox anchors.right: parent.right @@ -12,16 +12,17 @@ UIGame anchors.bottom: parent.bottom InterfacePanel2 - id: bottomPanel + id: gameBottomPanel height: 170 anchors.left: parent.left - anchors.right: rightPanel.left + anchors.right: gameRightPanel.left anchors.bottom: parent.bottom Map - id: mapPanel + id: gameMapPanel anchors.left: parent.left - anchors.right: rightPanel.left + anchors.right: gameRightPanel.left anchors.top: parent.top - anchors.bottom: bottomPanel.top + anchors.bottom: gameBottomPanel.top + focusable: false diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 8f734e42..a6446e56 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -23,7 +23,7 @@ local consoleBuffer local consoleTabBar local defaultChannelTab local serverLogTab -local current +local currentTab -- public functions function Console.create() @@ -33,6 +33,9 @@ function Console.create() consoleTabBar:setContentWidget(consoleBuffer) defaultChannelTab = consoleTabBar:addTab('Default') serverLogTab = consoleTabBar:addTab('Server Log') + + Hotkeys.bind('Tab', function() consoleTabBar:selectNextTab() end, consolePanel) + Hotkeys.bind('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel) end function Console.destroy() diff --git a/modules/game_console/console.otui b/modules/game_console/console.otui index 2b622db1..9afa2faa 100644 --- a/modules/game_console/console.otui +++ b/modules/game_console/console.otui @@ -69,4 +69,5 @@ Panel margin-right: 6 margin-left: 6 margin-bottom: 6 - always-active: true \ No newline at end of file + always-active: true + focusable: false \ No newline at end of file diff --git a/src/framework/luascript/luainterface.cpp b/src/framework/luascript/luainterface.cpp index 2460c2fb..64ad66ac 100644 --- a/src/framework/luascript/luainterface.cpp +++ b/src/framework/luascript/luainterface.cpp @@ -297,9 +297,13 @@ void LuaInterface::loadScript(const std::string& fileName) if(!boost::starts_with(fileName, "/")) filePath = getCurrentSourcePath() + "/" + filePath; - std::string buffer = g_resources.loadFile(filePath); - std::string source = "@" + filePath; - loadBuffer(buffer, source); + try { + std::string buffer = g_resources.loadFile(filePath); + std::string source = "@" + filePath; + loadBuffer(buffer, source); + } catch(Exception& e) { + throw LuaException(e.what()); + } } void LuaInterface::loadFunction(const std::string& buffer, const std::string& source) diff --git a/src/framework/platform/x11window.cpp b/src/framework/platform/x11window.cpp index d03ced63..9b72cbc7 100644 --- a/src/framework/platform/x11window.cpp +++ b/src/framework/platform/x11window.cpp @@ -77,8 +77,8 @@ X11Window::X11Window() m_keyMap[XK_Control_R] = Fw::KeyCtrl; m_keyMap[XK_Shift_R] = Fw::KeyShift; m_keyMap[XK_Shift_L] = Fw::KeyShift; - m_keyMap[XK_Alt_R] = Fw::KeyAlt; - m_keyMap[XK_Alt_L] = Fw::KeyAltGr; + m_keyMap[XK_Alt_R] = Fw::KeyAltGr; + m_keyMap[XK_Alt_L] = Fw::KeyAlt; m_keyMap[XK_Meta_L] = Fw::KeyMeta; m_keyMap[XK_Meta_R] = Fw::KeyMeta; m_keyMap[XK_Menu] = Fw::KeyMenu; @@ -642,13 +642,14 @@ void X11Window::poll() //logDebug("char: ", buf[0], " code: ", (uint)buf[0]); m_inputEvent.keyText = buf; } - } else { - len = XLookupString(&event.xkey, buf, sizeof(buf), &keysym, 0); - - if(len > 0) - m_inputEvent.keyText = buf; } + XKeyEvent xkey = event.xkey; + xkey.state = xkey.state & ~(ShiftMask); + len = XLookupString(&xkey, buf, sizeof(buf), &keysym, 0); + if(len > 0 && m_inputEvent.keyText.length() == 0) + m_inputEvent.keyText = buf; + if(m_keyMap.find(keysym) != m_keyMap.end()) m_inputEvent.keyCode = m_keyMap[keysym]; diff --git a/src/otclient/ui/uigame.cpp b/src/otclient/ui/uigame.cpp index 85eccbd9..cbabd322 100644 --- a/src/otclient/ui/uigame.cpp +++ b/src/otclient/ui/uigame.cpp @@ -27,6 +27,9 @@ bool UIGame::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifiers) { + if(UIWidget::onKeyPress(keyCode, keyText, keyboardModifiers)) + return true; + UILineEditPtr chatLineEdit = std::dynamic_pointer_cast(getParent()->recursiveGetChildById("consoleLineEdit")); if(keyboardModifiers == Fw::KeyboardNoModifier) { @@ -108,5 +111,5 @@ bool UIGame::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifier return true; } - return UIWidget::onKeyPress(keyCode, keyText, keyboardModifiers); + return false; }