diff options
Diffstat (limited to 'client/widgets')
-rw-r--r-- | client/widgets/widget.cc | 34 | ||||
-rw-r--r-- | client/widgets/widget.h | 1 | ||||
-rw-r--r-- | client/widgets/window.cc | 9 |
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; } |