From 6a91738f483ced67571d405e62b8bc4d972cb572 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 7 Jan 2019 05:03:00 +0100 Subject: [PATCH] Improvement in widget focusing --- examples/transparent.cpp | 7 ++----- src/fapplication.cpp | 2 +- src/fwidget.cpp | 13 +++++-------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/examples/transparent.cpp b/examples/transparent.cpp index 7d3aee29..524b4d1c 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -131,10 +131,8 @@ void Transparent::onKeyPress (finalcut::FKeyEvent* ev) if ( ev->key() == 'q' && getParentWidget() ) { - if ( getParentWidget()->close() ) - ev->accept(); - else - ev->ignore(); + getParentWidget()->close(); + ev->accept(); } else finalcut::FDialog::onKeyPress(ev); @@ -224,7 +222,6 @@ MainWindow::MainWindow (finalcut::FWidget* parent) // Statusbar at the bottom status_bar.setMessage("Press Q to quit"); - addAccelerator('q'); unsetTransparentShadow(); activateDialog(); } diff --git a/src/fapplication.cpp b/src/fapplication.cpp index e86d37f6..63b9611e 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -1192,7 +1192,7 @@ bool FApplication::processNextEvent() void FApplication::performTimerAction ( const FObject* receiver , const FEvent* event ) { - sendEvent(receiver, event); + sendEvent (receiver, event); } } // namespace finalcut diff --git a/src/fwidget.cpp b/src/fwidget.cpp index b12561ea..90f60474 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -267,16 +267,10 @@ bool FWidget::setFocus (bool enable) // set widget focus if ( enable && ! flags.focus ) { - int focusable_children = numOfFocusableChildren(); - if ( last_focus ) last_focus->unsetFocus(); - if ( (!isDialogWidget() && focusable_children == 0) - || (isDialogWidget() && focusable_children == 1) ) - { - FWidget::setFocusWidget(this); - } + FWidget::setFocusWidget(this); } auto window = FWindow::getWindowWidget(this); @@ -292,6 +286,7 @@ bool FWidget::setFocus (bool enable) if ( has_raised && window->isVisible() && window->isShown() ) window->redraw(); } + window->setWindowFocusWidget(this); } @@ -790,7 +785,9 @@ int FWidget::numOfFocusableChildren() { auto widget = static_cast(*iter); - if ( widget->acceptFocus() ) + if ( widget->isVisible() + && widget->acceptFocus() + && ! widget->isWindowWidget() ) num++; }