From 26dafdafbe6ac67479e7b78e77d6da178953a3ab Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Fri, 8 Feb 2008 18:36:06 -0800 Subject: fix highlighted menu item on mouse out --- src/FbTk/Menu.cc | 15 +++++++++++++-- src/FbTk/Menu.hh | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 696d847..ff57bde 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -832,8 +832,7 @@ void Menu::handleEvent(XEvent &event) { if (validIndex(m_which_sub) && menuitems[m_which_sub]->submenu()->isVisible()) menuitems[m_which_sub]->submenu()->grabInputFocus(); - } else if (event.type == LeaveNotify) - m_closing = false; + } } void Menu::buttonPressEvent(XButtonEvent &be) { @@ -1091,6 +1090,18 @@ void Menu::keyPressEvent(XKeyEvent &event) { } } +void Menu::leaveNotifyEvent(XCrossingEvent &ce) { + m_closing = false; + // if there's a submenu open, highlight its index and stop hide + if (validIndex(m_which_sub) && m_active_index != m_which_sub && + menuitems[m_which_sub]->submenu()->isVisible()) { + int old = m_active_index; + m_active_index = m_which_sub; + clearItem(m_active_index); + clearItem(old); + menuitems[m_which_sub]->submenu()->stopHide(); + } +} void Menu::reconfigure() { m_shape->setPlaces(theme()->shapePlaces()); diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 4ebab83..2675502 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -103,6 +103,7 @@ public: void motionNotifyEvent(XMotionEvent &mn); void exposeEvent(XExposeEvent &ee); void keyPressEvent(XKeyEvent &ke); + void leaveNotifyEvent(XCrossingEvent &ce); //@} /// get input focus void grabInputFocus(); -- cgit v0.11.2