summaryrefslogtreecommitdiff
path: root/client/widgets
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-12-01 09:33:12 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2011-12-01 09:33:12 +0100
commit45336cbecb6eff3317a365f271dc548c297f4ffa (patch)
tree523b507dd9eba7633cc309cbb8cdad83c7502250 /client/widgets
parent5d5595b9e1c1c22f7033a262b8174a5f3d05adc8 (diff)
Fix setKeyboardFocus to work recursive on all widgets. Fixes bug where MultiList did not receive keyboard focus when it is the first child in the macro window.
Diffstat (limited to 'client/widgets')
-rw-r--r--client/widgets/widget.cc34
-rw-r--r--client/widgets/widget.h1
-rw-r--r--client/widgets/window.cc9
3 files changed, 28 insertions, 16 deletions
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index ac90ef2..a57eb78 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -313,8 +313,26 @@ bool Widget::hidden()
bool Widget::setKeyboardFocus()
{
- widget->setFocus();
- return true;
+ if((widget->focusPolicy() & Qt::TabFocus) != 0) {
+ widget->setFocus();
+ return true;
+ }
+
+ return false;
+}
+
+bool Widget::setKeyboardFocusRecursive()
+{
+ if(setKeyboardFocus()) return true;
+
+ QVector< Widget* >::iterator i = children.begin();
+ while(i != children.end()) {
+ Widget *w = *i;
+ if(w && w->setKeyboardFocusRecursive()) return true;
+ i++;
+ }
+
+ return false;
}
Widget *Widget::findWidget(QString n, bool deep)
@@ -514,11 +532,13 @@ void Widget::createWidget(QDomNode &xml_node, QLayout *layout)
}
- addChild(widget);
-
- if(layout) layout->addWidget(widget->qwidget());
-
- if(widget && widget->qwidget()) widget->qwidget()->show();
+ if(widget) {
+ addChild(widget);
+ if(widget->qwidget()) {
+ if(layout) layout->addWidget(widget->qwidget());
+ widget->qwidget()->show();
+ }
+ }
}
int wdg_name(lua_State *L)
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index 4f23790..6199aa4 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -111,6 +111,7 @@ public:
virtual bool hidden();
virtual bool setKeyboardFocus();
+ bool setKeyboardFocusRecursive();
virtual void setForegroundColour(unsigned char red,
unsigned char green,
diff --git a/client/widgets/window.cc b/client/widgets/window.cc
index b491d44..7aa6374 100644
--- a/client/widgets/window.cc
+++ b/client/widgets/window.cc
@@ -65,14 +65,5 @@ Window::~Window()
bool Window::setKeyboardFocus()
{
- QVector< Widget* >::iterator i = children.begin();
- while(i != children.end()) {
- Widget *w = *i;
- if(w) {
- if(w->setKeyboardFocus()) return true;
- }
- i++;
- }
-
return false;
}