From b001ea9f1feb32a878b95a0b78c3fb0240f6df68 Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 13 Dec 2007 18:42:05 +0000 Subject: close menus when they lose focus, instead of on [exec] commands --- ChangeLog | 2 ++ src/FbTk/Menu.cc | 2 ++ src/MenuCreator.cc | 14 ++------------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c942584..1ac500c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 1.0.1: *07/12/13: + * Close menus only when they lose focus (Mark) + MenuCreator.cc FbTk/Menu.cc * Moved command parsing code all over the place -- expect any patches that add new commands to be broken (Mark, Simon) Added FbTk/CommandRegistry.cc/hh diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 4c41161..88240f1 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -815,6 +815,8 @@ void Menu::handleEvent(XEvent &event) { if (event.type == FocusOut) { if (s_focused == this) s_focused = 0; + if (shown == this && !m_torn) + hide(); // I don't know why, but I get a FocusIn event when closing the menu with // the mouse over it -- probably an xorg bug, but it's easy to address here } else if (event.type == FocusIn && m_visible) { diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index b98287b..0597d6c 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -256,21 +256,11 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConve // execute and hide menu using namespace FbTk; RefCount exec_cmd(FbTk::CommandRegistry::instance().parseLine("exec " + str_cmd)); - RefCount hide_menu(FbTk::CommandRegistry::instance().parseLine("hidemenus")); - MacroCommand *exec_and_hide = new FbTk::MacroCommand(); - exec_and_hide->add(hide_menu); - exec_and_hide->add(exec_cmd); - RefCount exec_and_hide_cmd(exec_and_hide); - menu.insert(str_label, exec_and_hide_cmd); + menu.insert(str_label, exec_cmd); } else if (str_key == "macrocmd") { using namespace FbTk; RefCount macro_cmd(FbTk::CommandRegistry::instance().parseLine("macrocmd " + str_cmd)); - RefCount hide_menu(FbTk::CommandRegistry::instance().parseLine("hidemenus")); - MacroCommand *exec_and_hide = new FbTk::MacroCommand(); - exec_and_hide->add(hide_menu); - exec_and_hide->add(macro_cmd); - RefCount exec_and_hide_cmd(exec_and_hide); - menu.insert(str_label, exec_and_hide_cmd); + menu.insert(str_label, macro_cmd); } else if (str_key == "style") { // style menu.insert(new StyleMenuItem(str_label, str_cmd)); } else if (str_key == "config") { -- cgit v0.11.2