Improvement in widget focusing

This commit is contained in:
Markus Gans 2019-01-07 05:03:00 +01:00
parent 2b110d87d8
commit 6a91738f48
3 changed files with 8 additions and 14 deletions

View File

@ -131,10 +131,8 @@ void Transparent::onKeyPress (finalcut::FKeyEvent* ev)
if ( ev->key() == 'q' && getParentWidget() ) if ( ev->key() == 'q' && getParentWidget() )
{ {
if ( getParentWidget()->close() ) getParentWidget()->close();
ev->accept(); ev->accept();
else
ev->ignore();
} }
else else
finalcut::FDialog::onKeyPress(ev); finalcut::FDialog::onKeyPress(ev);
@ -224,7 +222,6 @@ MainWindow::MainWindow (finalcut::FWidget* parent)
// Statusbar at the bottom // Statusbar at the bottom
status_bar.setMessage("Press Q to quit"); status_bar.setMessage("Press Q to quit");
addAccelerator('q');
unsetTransparentShadow(); unsetTransparentShadow();
activateDialog(); activateDialog();
} }

View File

@ -267,17 +267,11 @@ bool FWidget::setFocus (bool enable)
// set widget focus // set widget focus
if ( enable && ! flags.focus ) if ( enable && ! flags.focus )
{ {
int focusable_children = numOfFocusableChildren();
if ( last_focus ) if ( last_focus )
last_focus->unsetFocus(); last_focus->unsetFocus();
if ( (!isDialogWidget() && focusable_children == 0)
|| (isDialogWidget() && focusable_children == 1) )
{
FWidget::setFocusWidget(this); FWidget::setFocusWidget(this);
} }
}
auto window = FWindow::getWindowWidget(this); auto window = FWindow::getWindowWidget(this);
@ -292,6 +286,7 @@ bool FWidget::setFocus (bool enable)
if ( has_raised && window->isVisible() && window->isShown() ) if ( has_raised && window->isVisible() && window->isShown() )
window->redraw(); window->redraw();
} }
window->setWindowFocusWidget(this); window->setWindowFocusWidget(this);
} }
@ -790,7 +785,9 @@ int FWidget::numOfFocusableChildren()
{ {
auto widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( widget->acceptFocus() ) if ( widget->isVisible()
&& widget->acceptFocus()
&& ! widget->isWindowWidget() )
num++; num++;
} }