map losing focus fix

master
Eduardo Bart 13 years ago
parent 67d8112ed0
commit 12661c1b1b

@ -1,4 +1,5 @@
UIWidget UIWidget
id: gameRootInterface
anchors.fill: parent anchors.fill: parent
UIMap UIMap

@ -41,6 +41,7 @@ local function tryLogin(charInfo, tries)
loadBox = displayCancelBox('Please wait', 'Connecting to game server...') loadBox = displayCancelBox('Please wait', 'Connecting to game server...')
function loadBox.onCancel() function loadBox.onCancel()
loadBox = nil
Game.cancelLogin() Game.cancelLogin()
CharacterList.show() CharacterList.show()
end end

@ -17,7 +17,7 @@ MainWindow
title: Charlist title: Charlist
size: 250 250 size: 250 250
onEnter: CharacterList.doLogin() onEnter: CharacterList.doLogin()
onEscape: function(self) self:destroy() end onEscape: CharacterList.hide()
TextList TextList
id: characterList id: characterList

@ -109,6 +109,15 @@ void UIWidget::render()
} }
} }
void UIWidget::setVisible(bool visible)
{
m_visible = visible;
if(!visible && isFocused()) {
if(UIWidgetPtr parent = getParent())
parent->focusNextChild(Fw::ActiveFocusReason);
}
}
void UIWidget::setStyle(const std::string& styleName) void UIWidget::setStyle(const std::string& styleName)
{ {
OTMLNodePtr styleNode = g_ui.getStyle(styleName); OTMLNodePtr styleNode = g_ui.getStyle(styleName);
@ -418,7 +427,7 @@ void UIWidget::focusNextChild(Fw::FocusReason reason)
// finds next child to focus // finds next child to focus
for(const UIWidgetPtr& child : rotatedChildren) { for(const UIWidgetPtr& child : rotatedChildren) {
if(child->isFocusable()) { if(child->isFocusable() && child->isExplicitlyEnabled() && child->isVisible()) {
toFocus = child; toFocus = child;
break; break;
} }
@ -444,7 +453,7 @@ void UIWidget::focusPreviousChild(Fw::FocusReason reason)
// finds next child to focus // finds next child to focus
for(const UIWidgetPtr& child : rotatedChildren) { for(const UIWidgetPtr& child : rotatedChildren) {
if(child->isFocusable()) { if(child->isFocusable() && child->isExplicitlyEnabled() && child->isVisible()) {
toFocus = child; toFocus = child;
break; break;
} }

@ -41,8 +41,8 @@ public:
virtual void setup(); virtual void setup();
virtual void render(); virtual void render();
void setVisible(bool visible);
void setEnabled(bool enabled) { m_enabled = enabled; updateState(Fw::DisabledState); } void setEnabled(bool enabled) { m_enabled = enabled; updateState(Fw::DisabledState); }
void setVisible(bool visible) { m_visible = visible; }
void setPressed(bool pressed) { m_pressed = pressed; updateState(Fw::PressedState); } void setPressed(bool pressed) { m_pressed = pressed; updateState(Fw::PressedState); }
void setId(const std::string& id) { m_id = id; } void setId(const std::string& id) { m_id = id; }
void setFocusable(bool focusable) { m_focusable = focusable; } void setFocusable(bool focusable) { m_focusable = focusable; }

@ -293,11 +293,11 @@ void OTClient::onPlatformEvent(const PlatformEvent& event)
// TODO: move this events to lua // TODO: move this events to lua
UIWidgetPtr console = g_ui.getRootWidget()->getChildById("consolePanel"); UIWidgetPtr console = g_ui.getRootWidget()->getChildById("consolePanel");
if(!console->isExplicitlyVisible()) { if(!console->isExplicitlyVisible()) {
g_ui.getRootWidget()->lockChild(console); console->lock();
console->setVisible(true); console->show();
} else { } else {
g_ui.getRootWidget()->unlockChild(console); console->unlock();
console->setVisible(false); console->hide();
} }
fireUi = false; fireUi = false;
} }

Loading…
Cancel
Save