Small menu improvements
This commit is contained in:
parent
692f8248e1
commit
70dd5af0fb
|
@ -1,3 +1,6 @@
|
||||||
|
2015-11-25 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Small menu improvements
|
||||||
|
|
||||||
2015-11-24 Markus Gans <guru.mail@muenster.de>
|
2015-11-24 Markus Gans <guru.mail@muenster.de>
|
||||||
* Improved mouse and keyboard handling in sub-menus
|
* Improved mouse and keyboard handling in sub-menus
|
||||||
|
|
||||||
|
|
|
@ -401,16 +401,11 @@ bool FMenu::selectPrevItem()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenu::keypressMenuBar (FKeyEvent*& ev)
|
void FMenu::keypressMenuBar (FKeyEvent*& ev)
|
||||||
{
|
{
|
||||||
FWidget* super = getSuperMenu();
|
FMenuBar* mbar = menuBar();
|
||||||
if ( super )
|
|
||||||
{
|
if ( mbar )
|
||||||
if ( isMenuBar(super) )
|
|
||||||
{
|
|
||||||
FMenuBar* mbar = reinterpret_cast<FMenuBar*>(super);
|
|
||||||
mbar->onKeyPress(ev);
|
mbar->onKeyPress(ev);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FMenu::hotkeyMenu (FKeyEvent*& ev)
|
bool FMenu::hotkeyMenu (FKeyEvent*& ev)
|
||||||
|
@ -436,6 +431,18 @@ bool FMenu::hotkeyMenu (FKeyEvent*& ev)
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
if ( found )
|
if ( found )
|
||||||
|
{
|
||||||
|
if ( (*iter)->hasMenu() )
|
||||||
|
{
|
||||||
|
FMenu* sub_menu = (*iter)->getMenu();
|
||||||
|
unselectItem();
|
||||||
|
(*iter)->setSelected();
|
||||||
|
setSelectedItem (*iter);
|
||||||
|
redraw();
|
||||||
|
openSubMenu (sub_menu);
|
||||||
|
sub_menu->redraw();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
unselectItem();
|
unselectItem();
|
||||||
hideSubMenus();
|
hideSubMenus();
|
||||||
|
@ -445,6 +452,7 @@ bool FMenu::hotkeyMenu (FKeyEvent*& ev)
|
||||||
flush_out();
|
flush_out();
|
||||||
ev->accept();
|
ev->accept();
|
||||||
(*iter)->processClicked();
|
(*iter)->processClicked();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1180,10 +1188,11 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||||
const FPoint& g = ev->getGlobalPos();
|
const FPoint& g = ev->getGlobalPos();
|
||||||
const FPoint& p = open_sub_menu->globalToLocalPos(g);
|
const FPoint& p = open_sub_menu->globalToLocalPos(g);
|
||||||
int b = ev->getButton();
|
int b = ev->getButton();
|
||||||
ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
FMouseEvent* _ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
||||||
open_sub_menu->mouse_down = true;
|
open_sub_menu->mouse_down = true;
|
||||||
setClickedWidget(open_sub_menu);
|
setClickedWidget(open_sub_menu);
|
||||||
open_sub_menu->onMouseMove(ev);
|
open_sub_menu->onMouseMove(_ev);
|
||||||
|
delete _ev;
|
||||||
}
|
}
|
||||||
else if ( ! mouse_over_menu && mouse_over_supermenu )
|
else if ( ! mouse_over_menu && mouse_over_supermenu )
|
||||||
{
|
{
|
||||||
|
@ -1191,10 +1200,11 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||||
const FPoint& g = ev->getGlobalPos();
|
const FPoint& g = ev->getGlobalPos();
|
||||||
const FPoint& p = smenu->globalToLocalPos(g);
|
const FPoint& p = smenu->globalToLocalPos(g);
|
||||||
int b = ev->getButton();
|
int b = ev->getButton();
|
||||||
ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
FMouseEvent* _ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
||||||
smenu->mouse_down = true;
|
smenu->mouse_down = true;
|
||||||
setClickedWidget(smenu);
|
setClickedWidget(smenu);
|
||||||
smenu->onMouseMove(ev);
|
smenu->onMouseMove(_ev);
|
||||||
|
delete _ev;
|
||||||
}
|
}
|
||||||
else if ( mouse_over_menubar )
|
else if ( mouse_over_menubar )
|
||||||
{
|
{
|
||||||
|
@ -1203,12 +1213,12 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||||
const FPoint& g = ev->getGlobalPos();
|
const FPoint& g = ev->getGlobalPos();
|
||||||
const FPoint& p = menubar->globalToLocalPos(g);
|
const FPoint& p = menubar->globalToLocalPos(g);
|
||||||
int b = ev->getButton();
|
int b = ev->getButton();
|
||||||
ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
FMouseEvent* _ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
||||||
setClickedWidget(menubar);
|
setClickedWidget(menubar);
|
||||||
FMenuBar* mbar = reinterpret_cast<FMenuBar*>(menubar);
|
FMenuBar* mbar = reinterpret_cast<FMenuBar*>(menubar);
|
||||||
mbar->mouse_down = true;
|
mbar->mouse_down = true;
|
||||||
mbar->onMouseMove(ev);
|
mbar->onMouseMove(_ev);
|
||||||
delete ev;
|
delete _ev;
|
||||||
}
|
}
|
||||||
else if ( ! hasSelectedItem() && statusBar() && mouse_over_menu )
|
else if ( ! hasSelectedItem() && statusBar() && mouse_over_menu )
|
||||||
{
|
{
|
||||||
|
|
|
@ -772,10 +772,11 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
|
||||||
const FPoint& g = ev->getGlobalPos();
|
const FPoint& g = ev->getGlobalPos();
|
||||||
const FPoint& p = menu->globalToLocalPos(g);
|
const FPoint& p = menu->globalToLocalPos(g);
|
||||||
int b = ev->getButton();
|
int b = ev->getButton();
|
||||||
ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
FMouseEvent* _ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
||||||
menu->mouse_down = true;
|
menu->mouse_down = true;
|
||||||
setClickedWidget(menu);
|
setClickedWidget(menu);
|
||||||
menu->onMouseMove(ev);
|
menu->onMouseMove(_ev);
|
||||||
|
delete _ev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,11 +174,12 @@ void FMenuItem::init (FWidget* parent)
|
||||||
{
|
{
|
||||||
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent);
|
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent);
|
||||||
if ( menubar_ptr )
|
if ( menubar_ptr )
|
||||||
|
{
|
||||||
menubar_ptr->menu_dimension();
|
menubar_ptr->menu_dimension();
|
||||||
|
|
||||||
// Meta + hotkey
|
if ( hotkey ) // Meta + hotkey
|
||||||
if ( hotkey )
|
|
||||||
menubar_ptr->addAccelerator (fc::Fmkey_meta + tolower(hotkey), this);
|
menubar_ptr->addAccelerator (fc::Fmkey_meta + tolower(hotkey), this);
|
||||||
|
}
|
||||||
|
|
||||||
this->addCallback
|
this->addCallback
|
||||||
(
|
(
|
||||||
|
@ -382,9 +383,9 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
|
||||||
if ( smenu )
|
if ( smenu )
|
||||||
{
|
{
|
||||||
const FPoint& p2 = smenu->globalToLocalPos(g);
|
const FPoint& p2 = smenu->globalToLocalPos(g);
|
||||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
FMouseEvent* _ev = new FMouseEvent (MouseDown_Event, p2, g, b);
|
||||||
smenu->onMouseDown(ev);
|
smenu->onMouseDown(_ev);
|
||||||
delete ev;
|
delete _ev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,9 +395,9 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
|
||||||
if ( mbar )
|
if ( mbar )
|
||||||
{
|
{
|
||||||
const FPoint& p2 = mbar->globalToLocalPos(g);
|
const FPoint& p2 = mbar->globalToLocalPos(g);
|
||||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
FMouseEvent* _ev = new FMouseEvent (MouseDown_Event, p2, g, b);
|
||||||
mbar->onMouseDown(ev);
|
mbar->onMouseDown(_ev);
|
||||||
delete ev;
|
delete _ev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,9 +417,9 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
|
||||||
if ( smenu )
|
if ( smenu )
|
||||||
{
|
{
|
||||||
const FPoint& p2 = smenu->globalToLocalPos(g);
|
const FPoint& p2 = smenu->globalToLocalPos(g);
|
||||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
FMouseEvent* _ev = new FMouseEvent (MouseUp_Event, p2, g, b);
|
||||||
smenu->onMouseUp(ev);
|
smenu->onMouseUp(_ev);
|
||||||
delete ev;
|
delete _ev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,9 +429,9 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
|
||||||
if ( mbar )
|
if ( mbar )
|
||||||
{
|
{
|
||||||
const FPoint& p2 = mbar->globalToLocalPos(g);
|
const FPoint& p2 = mbar->globalToLocalPos(g);
|
||||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
FMouseEvent* _ev = new FMouseEvent (MouseUp_Event, p2, g, b);
|
||||||
mbar->onMouseUp(ev);
|
mbar->onMouseUp(_ev);
|
||||||
delete ev;
|
delete _ev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -450,9 +451,9 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
|
||||||
if ( smenu )
|
if ( smenu )
|
||||||
{
|
{
|
||||||
const FPoint& p2 = smenu->globalToLocalPos(g);
|
const FPoint& p2 = smenu->globalToLocalPos(g);
|
||||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
FMouseEvent* _ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||||
smenu->onMouseMove(ev);
|
smenu->onMouseMove(_ev);
|
||||||
delete ev;
|
delete _ev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,9 +463,9 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
|
||||||
if ( mbar )
|
if ( mbar )
|
||||||
{
|
{
|
||||||
const FPoint& p2 = mbar->globalToLocalPos(g);
|
const FPoint& p2 = mbar->globalToLocalPos(g);
|
||||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
FMouseEvent* _ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||||
mbar->onMouseMove(ev);
|
mbar->onMouseMove(_ev);
|
||||||
delete ev;
|
delete _ev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,27 +651,27 @@ void FMenuItem::unsetSelected()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenuItem::openMenu()
|
void FMenuItem::openMenu()
|
||||||
{
|
{
|
||||||
FMenu* menu;
|
FMenu* dd_menu; // Drop-down menu
|
||||||
FMenu* open_menu;
|
FMenu* open_menu;
|
||||||
|
|
||||||
if ( hasMenu() )
|
if ( hasMenu() )
|
||||||
{
|
{
|
||||||
menu = getMenu();
|
dd_menu = getMenu();
|
||||||
if ( menu->isVisible() )
|
if ( dd_menu->isVisible() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
open_menu = static_cast<FMenu*>(getOpenMenu());
|
open_menu = static_cast<FMenu*>(getOpenMenu());
|
||||||
if ( open_menu && open_menu != menu )
|
if ( open_menu && open_menu != dd_menu )
|
||||||
{
|
{
|
||||||
open_menu->hide();
|
open_menu->hide();
|
||||||
open_menu->hideSubMenus();
|
open_menu->hideSubMenus();
|
||||||
}
|
}
|
||||||
setOpenMenu(menu);
|
setOpenMenu(dd_menu);
|
||||||
|
|
||||||
menu->setVisible();
|
dd_menu->setVisible();
|
||||||
menu->show();
|
dd_menu->show();
|
||||||
menu->raiseWindow(menu);
|
dd_menu->raiseWindow(dd_menu);
|
||||||
menu->redraw();
|
dd_menu->redraw();
|
||||||
updateTerminal();
|
updateTerminal();
|
||||||
flush_out();
|
flush_out();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue