Code simplification
This commit is contained in:
parent
71b5b16865
commit
b7c11c7c90
|
@ -583,8 +583,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
|
||||||
|
|
||||||
if ( mouse_y == 1 )
|
if ( mouse_y == 1 )
|
||||||
{
|
{
|
||||||
if ( mouse_x >= x1
|
if ( mouse_x >= x1 && mouse_x < x2 )
|
||||||
&& mouse_x < x2 )
|
|
||||||
{
|
{
|
||||||
// Mouse pointer over item
|
// Mouse pointer over item
|
||||||
if ( (*iter)->isEnabled() && ! (*iter)->isSelected() )
|
if ( (*iter)->isEnabled() && ! (*iter)->isSelected() )
|
||||||
|
@ -662,49 +661,49 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
|
||||||
|
|
||||||
if ( mouse_y == 1 )
|
if ( mouse_y == 1 )
|
||||||
{
|
{
|
||||||
if ( mouse_x >= x1
|
if ( (*iter)->isEnabled() && (*iter)->isSelected() )
|
||||||
&& mouse_x < x2
|
|
||||||
&& (*iter)->isEnabled()
|
|
||||||
&& (*iter)->isSelected() )
|
|
||||||
{
|
{
|
||||||
// Mouse pointer over item
|
if ( mouse_x >= x1 && mouse_x < x2 )
|
||||||
if ( (*iter)->hasMenu() )
|
|
||||||
{
|
{
|
||||||
FMenu* menu = (*iter)->getMenu();
|
// Mouse pointer over item
|
||||||
if ( ! menu->hasSelectedItem() )
|
if ( (*iter)->hasMenu() )
|
||||||
{
|
{
|
||||||
FMenuItem* first_item;
|
FMenu* menu = (*iter)->getMenu();
|
||||||
menu->selectFirstItem();
|
if ( ! menu->hasSelectedItem() )
|
||||||
first_item = menu->getSelectedItem();
|
{
|
||||||
if ( first_item )
|
FMenuItem* first_item;
|
||||||
first_item->setFocus();
|
menu->selectFirstItem();
|
||||||
menu->redraw();
|
first_item = menu->getSelectedItem();
|
||||||
if ( statusBar() )
|
if ( first_item )
|
||||||
statusBar()->drawMessage();
|
first_item->setFocus();
|
||||||
redraw();
|
menu->redraw();
|
||||||
drop_down = true;
|
if ( statusBar() )
|
||||||
|
statusBar()->drawMessage();
|
||||||
|
redraw();
|
||||||
|
drop_down = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(*iter)->unsetSelected();
|
||||||
|
if ( getSelectedItem() == *iter )
|
||||||
|
{
|
||||||
|
setSelectedItem(0);
|
||||||
|
leaveMenuBar();
|
||||||
|
drop_down = false;
|
||||||
|
(*iter)->processClicked();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*iter)->unsetSelected();
|
(*iter)->unsetSelected();
|
||||||
if ( getSelectedItem() == *iter )
|
if ( getSelectedItem() == *iter )
|
||||||
{
|
|
||||||
setSelectedItem(0);
|
setSelectedItem(0);
|
||||||
leaveMenuBar();
|
redraw();
|
||||||
drop_down = false;
|
|
||||||
(*iter)->processClicked();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( (*iter)->isEnabled() && (*iter)->isSelected() )
|
|
||||||
{
|
|
||||||
(*iter)->unsetSelected();
|
|
||||||
if ( getSelectedItem() == *iter )
|
|
||||||
setSelectedItem(0);
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue