diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2011-12-01 09:33:12 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2011-12-01 09:33:12 +0100 |
commit | 45336cbecb6eff3317a365f271dc548c297f4ffa (patch) | |
tree | 523b507dd9eba7633cc309cbb8cdad83c7502250 /client | |
parent | 5d5595b9e1c1c22f7033a262b8174a5f3d05adc8 (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')
-rw-r--r-- | client/macrowindow.cc | 2 | ||||
-rw-r--r-- | client/widgets/widget.cc | 34 | ||||
-rw-r--r-- | client/widgets/widget.h | 1 | ||||
-rw-r--r-- | client/widgets/window.cc | 9 |
4 files changed, 29 insertions, 17 deletions
diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 48ace4e..f924d8c 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -328,6 +328,6 @@ void MacroWindow::animated(QWidget *w) setTabOrderRecursive(scrollarea); // Set keyboard focus on the first focusable widget in the macro. - mainwidget->setKeyboardFocus(); + mainwidget->setKeyboardFocusRecursive(); } } 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; } |