Improve focusFirstChild() and focusLastChild()

This commit is contained in:
Markus Gans 2015-07-12 21:49:30 +02:00
parent 9420e2050a
commit 0485138c33
5 changed files with 20 additions and 14 deletions

View File

@ -1,3 +1,6 @@
2015-06-12 Markus Gans <guru.mail@muenster.de>
* Improve focusFirstChild() and focusLastChild()
2015-06-09 Markus Gans <guru.mail@muenster.de>
* Better contrast on 8 color terminals

View File

@ -110,9 +110,11 @@ void FDialog::init()
this->flags |= ACTIVE;
FWidget* old_focus = FWidget::getFocusWidget();
setFocus();
if ( old_focus )
{
setFocus();
old_focus->redraw();
}
accelerator_list = new Accelerators;
}

View File

@ -1278,13 +1278,15 @@ bool FWidget::focusFirstChild (void)
while ( iter != end )
{
FWidget* widget = static_cast<FWidget*>(*iter);
if ( widget->isEnabled()
&& widget->acceptFocus()
&& ! widget->isWindow() )
if ( widget->isEnabled() && widget->acceptFocus() )
{
widget->setFocus(true);
if ( widget->numOfChildren() >= 1 )
widget->focusFirstChild();
{
if ( ! widget->focusFirstChild() )
continue;
}
else
widget->setFocus();
return true;
}
// prefix increment (++) is faster
@ -1311,13 +1313,15 @@ bool FWidget::focusLastChild (void)
{
--iter;
FWidget* widget = static_cast<FWidget*>(*iter);
if ( widget->isEnabled()
&& widget->acceptFocus()
&& ! widget->isWindow() )
if ( widget->isEnabled() && widget->acceptFocus() )
{
widget->setFocus(true);
if ( widget->numOfChildren() >= 1 )
widget->focusLastChild();
{
if ( ! widget->focusLastChild() )
continue;
}
else
widget->setFocus();
return true;
}
}

View File

@ -79,8 +79,6 @@ int main (int argc, char* argv[])
st_field->setShadow();
c_field->setShadow();
name_field->setFocus();
// Create the button group
FButtonGroup* radioButtonGroup = new FButtonGroup("Sex", &dgl);
radioButtonGroup->setGeometry(2, 13, 13, 4);

View File

@ -61,7 +61,6 @@ watch::watch (FWidget* parent) : FDialog(parent)
seconds_sw = new FSwitch(L"Seconds", this);
clock_sw->setGeometry(4, 4, 9, 1);
seconds_sw->setGeometry(2, 6, 11, 1);
clock_sw->setFocus();
sec = seconds_sw->setChecked();
// Create button