map losing focus fix

This commit is contained in:
Eduardo Bart 2011-08-29 20:40:56 -03:00
parent 67d8112ed0
commit 12661c1b1b
6 changed files with 19 additions and 8 deletions

View File

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

View File

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

View File

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

View File

@ -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)
{
OTMLNodePtr styleNode = g_ui.getStyle(styleName);
@ -418,7 +427,7 @@ void UIWidget::focusNextChild(Fw::FocusReason reason)
// finds next child to focus
for(const UIWidgetPtr& child : rotatedChildren) {
if(child->isFocusable()) {
if(child->isFocusable() && child->isExplicitlyEnabled() && child->isVisible()) {
toFocus = child;
break;
}
@ -444,7 +453,7 @@ void UIWidget::focusPreviousChild(Fw::FocusReason reason)
// finds next child to focus
for(const UIWidgetPtr& child : rotatedChildren) {
if(child->isFocusable()) {
if(child->isFocusable() && child->isExplicitlyEnabled() && child->isVisible()) {
toFocus = child;
break;
}

View File

@ -41,8 +41,8 @@ public:
virtual void setup();
virtual void render();
void setVisible(bool visible);
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 setId(const std::string& id) { m_id = id; }
void setFocusable(bool focusable) { m_focusable = focusable; }

View File

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