From 688d413b8c3b21c5d3d7d4ba09ccfb265dae071e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 14 Jul 2014 11:06:12 +0200 Subject: [PATCH] when scene toolbar gains focus, focus first button --- apps/opencs/view/widget/scenetoolbar.cpp | 8 ++++++++ apps/opencs/view/widget/scenetoolbar.hpp | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/apps/opencs/view/widget/scenetoolbar.cpp b/apps/opencs/view/widget/scenetoolbar.cpp index 59a3a1d6e2..f06c856cb9 100644 --- a/apps/opencs/view/widget/scenetoolbar.cpp +++ b/apps/opencs/view/widget/scenetoolbar.cpp @@ -5,6 +5,14 @@ #include "scenetool.hpp" +void CSVWidget::SceneToolbar::focusInEvent (QFocusEvent *event) +{ + QWidget::focusInEvent (event); + + if (mLayout->count()) + dynamic_cast (*mLayout->itemAt (0)).widget()->setFocus(); +} + CSVWidget::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent) : QWidget (parent), mButtonSize (buttonSize), mIconSize (buttonSize-6) { diff --git a/apps/opencs/view/widget/scenetoolbar.hpp b/apps/opencs/view/widget/scenetoolbar.hpp index 0ef84f488e..bd609078db 100644 --- a/apps/opencs/view/widget/scenetoolbar.hpp +++ b/apps/opencs/view/widget/scenetoolbar.hpp @@ -17,6 +17,10 @@ namespace CSVWidget int mButtonSize; int mIconSize; + protected: + + virtual void focusInEvent (QFocusEvent *event); + public: SceneToolbar (int buttonSize, QWidget *parent = 0);