Skip to content

Commit

Permalink
Make edit boxes always focusable and child windows only when they con…
Browse files Browse the repository at this point in the history
…tain a focusable widget
  • Loading branch information
texus committed Sep 5, 2013
1 parent 7ae816d commit ae80e7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
24 changes: 14 additions & 10 deletions src/TGUI/Container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2915,19 +2915,23 @@ namespace tgui
// Make sure that the widget is visible and enabled
if ((m_Widgets[i]->m_Visible) && (m_Widgets[i]->m_Enabled))
{
if (m_FocusedWidget > 0)
// Container widgets can only be focused it they contain focusable widgets
if ((!m_Widgets[i]->m_ContainerWidget) || (Container::Ptr(m_Widgets[i])->focusNextWidgetInContainer()))
{
// Unfocus the current widget
m_Widgets[m_FocusedWidget-1]->m_Focused = false;
m_Widgets[m_FocusedWidget-1]->widgetUnfocused();
}
if (m_FocusedWidget > 0)
{
// Unfocus the current widget
m_Widgets[m_FocusedWidget-1]->m_Focused = false;
m_Widgets[m_FocusedWidget-1]->widgetUnfocused();
}

// Focus on the new widget
m_FocusedWidget = i+1;
m_Widgets[i]->m_Focused = true;
m_Widgets[i]->widgetFocused();
// Focus on the new widget
m_FocusedWidget = i+1;
m_Widgets[i]->m_Focused = true;
m_Widgets[i]->widgetFocused();

return true;
return true;
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/TGUI/EditBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace tgui
m_Callback.widgetType = Type_EditBox;
m_AnimatedWidget = true;
m_DraggableWidget = true;
m_AllowFocus = true;

m_SelectionPoint.setSize(sf::Vector2f(1, 0));

Expand Down Expand Up @@ -383,7 +384,6 @@ namespace tgui
// Check if optional textures were loaded
if ((m_TextureFocused_L.data != nullptr) && (m_TextureFocused_M.data != nullptr) && (m_TextureFocused_R.data != nullptr))
{
m_AllowFocus = true;
m_WidgetPhase |= WidgetPhase_Focused;
}
if ((m_TextureHover_L.data != nullptr) && (m_TextureHover_M.data != nullptr) && (m_TextureHover_R.data != nullptr))
Expand All @@ -408,7 +408,6 @@ namespace tgui
// Check if optional textures were loaded
if (m_TextureFocused_M.data != nullptr)
{
m_AllowFocus = true;
m_WidgetPhase |= WidgetPhase_Focused;
}
if (m_TextureHover_M.data != nullptr)
Expand Down

0 comments on commit ae80e7d

Please sign in to comment.