summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/focushandler.cpp37
-rw-r--r--src/gui/focushandler.h13
2 files changed, 50 insertions, 0 deletions
diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp
index de10fece..9a0ba6b4 100644
--- a/src/gui/focushandler.cpp
+++ b/src/gui/focushandler.cpp
@@ -21,6 +21,8 @@
#include "focushandler.h"
+#include "gui/widgets/window.h"
+
void FocusHandler::requestModalFocus(gcn::Widget *widget)
{
/* If there is another widget with modal focus, remove its modal focus
@@ -60,3 +62,38 @@ void FocusHandler::remove(gcn::Widget *widget)
gcn::FocusHandler::remove(widget);
}
+
+void FocusHandler::tabNext()
+{
+ gcn::FocusHandler::tabNext();
+
+ checkForWindow();
+}
+
+void FocusHandler::tabPrevious()
+{
+ gcn::FocusHandler::tabPrevious();
+
+ checkForWindow();
+}
+
+void FocusHandler::checkForWindow()
+{
+ if (mFocusedWidget)
+ {
+ gcn::Widget *widget = mFocusedWidget->getParent();
+
+ while (widget)
+ {
+ Window *window = dynamic_cast<Window*>(widget);
+
+ if (window)
+ {
+ window->requestMoveToTop();
+ break;
+ }
+
+ widget = widget->getParent();
+ }
+ }
+}
diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h
index aaac6ca6..d4c4e14f 100644
--- a/src/gui/focushandler.h
+++ b/src/gui/focushandler.h
@@ -54,8 +54,21 @@ class FocusHandler : public gcn::FocusHandler
*/
void remove(gcn::Widget *widget);
+ /**
+ * Overloaded to allow windows to move to the top when one of their
+ * widgets is tabbed to when tabbing through focusable elements.
+ */
+ void tabNext();
+ void tabPrevious();
+
private:
/**
+ * Checks to see if the widget tabbed to is in a window, and if it is,
+ * it requests the window be moved to the top.
+ */
+ void checkForWindow();
+
+ /**
* Stack of widgets that have requested modal forcus.
*/
std::list<gcn::Widget*> mModalStack;