holding control will now keep the menu open
This commit is contained in:
parent
31df2d8bd6
commit
c01bd6e9fd
18 changed files with 64 additions and 42 deletions
|
@ -1,5 +1,8 @@
|
|||
(Format: Year/Month/Day)
|
||||
Changes for 1.0.1:
|
||||
*07/12/18:
|
||||
* Holding control while clicking on a menu item will now keep the menu open (Mark)
|
||||
FbTk/Menu.cc MenuItem.cc/hh
|
||||
*07/12/17:
|
||||
* Fix startup items in apps file with specified screen number, bug #1843325
|
||||
(thanks Martin)
|
||||
|
|
|
@ -64,17 +64,18 @@ public:
|
|||
AlphaMenuSelectItem(const FbTk::FbString &label, AlphaObject *object, AlphaMenu &parent):
|
||||
FbTk::MenuItem(label), m_object(object), m_parent(parent) {
|
||||
setToggleItem(true);
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
|
||||
bool isSelected() const { return m_object->getUseDefaultAlpha(); }
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
bool newval = !m_object->getUseDefaultAlpha();
|
||||
m_object->setUseDefaultAlpha(newval);
|
||||
// items 1 and 2 (the focused/unfocused values) are only enabled if we don't use default values
|
||||
m_parent.setItemEnabled(1, !newval);
|
||||
m_parent.setItemEnabled(2, !newval);
|
||||
m_parent.show(); // cheat to refreshing the window
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
|
||||
void updateLabel() {
|
||||
|
|
|
@ -44,7 +44,10 @@ public:
|
|||
}
|
||||
bool isSelected() const { return m_item; }
|
||||
// toggle state
|
||||
void click(int button, int time) { setSelected(!m_item); FbTk::MenuItem::click(button, time); }
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
setSelected(!m_item);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
void setSelected(bool value) {
|
||||
m_item = value;
|
||||
FbTk::MenuItem::setSelected(m_item);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Screen.hh"
|
||||
#include "Window.hh"
|
||||
#include "WindowCmd.hh"
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#include "FbTk/MenuItem.hh"
|
||||
|
||||
|
@ -42,7 +43,7 @@ public:
|
|||
}
|
||||
~ClientMenuItem() { m_client.titleSig().detach(menu()); }
|
||||
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
FluxboxWindow *fbwin = m_client.fbwindow();
|
||||
if (fbwin == 0)
|
||||
return;
|
||||
|
@ -53,7 +54,8 @@ public:
|
|||
|
||||
m_client.focus();
|
||||
fbwin->raise();
|
||||
parent->hide();
|
||||
if ((mods & ControlMask) == 0)
|
||||
parent->hide();
|
||||
}
|
||||
|
||||
const std::string &label() const { return m_client.title(); }
|
||||
|
|
|
@ -61,9 +61,10 @@ public:
|
|||
setLabel( _FB_XTEXT(Toolbar, Clock24, "Clock: 24h", "set Clockmode to 24h") );
|
||||
else
|
||||
setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") );
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
std::string newformat = m_tool.timeFormat();
|
||||
size_t pos = newformat.find("%k");
|
||||
std::string newstr;
|
||||
|
@ -112,7 +113,7 @@ public:
|
|||
setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") );
|
||||
|
||||
} // else some other strange format...so we don't do anything
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
private:
|
||||
ClockTool &m_tool;
|
||||
|
|
|
@ -888,7 +888,7 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) {
|
|||
if (m_active_index == w && isItemEnabled(w) &&
|
||||
re.x > ix && re.x < (signed) (ix + menu.item_w) &&
|
||||
re.y > iy && re.y < (signed) (iy + theme().itemHeight())) {
|
||||
menuitems[w]->click(re.button, re.time);
|
||||
menuitems[w]->click(re.button, re.time, re.state);
|
||||
} else {
|
||||
int old = m_active_index;
|
||||
m_active_index = w;
|
||||
|
@ -1054,7 +1054,7 @@ void Menu::keyPressEvent(XKeyEvent &event) {
|
|||
else {
|
||||
// send fake button click
|
||||
int button = (event.state & ShiftMask) ? 3 : 1;
|
||||
find(m_active_index)->click(button, event.time);
|
||||
find(m_active_index)->click(button, event.time, event.state);
|
||||
m_need_update = true;
|
||||
updateMenu();
|
||||
}
|
||||
|
|
|
@ -30,12 +30,13 @@
|
|||
#include "App.hh"
|
||||
#include "StringUtil.hh"
|
||||
#include "Menu.hh"
|
||||
#include <X11/keysym.h>
|
||||
|
||||
namespace FbTk {
|
||||
|
||||
void MenuItem::click(int button, int time) {
|
||||
void MenuItem::click(int button, int time, unsigned int mods) {
|
||||
if (m_command.get() != 0) {
|
||||
if (m_menu && m_close_on_click)
|
||||
if (m_menu && m_close_on_click && (mods & ControlMask) == 0)
|
||||
m_menu->hide();
|
||||
// we need a local variable, since the command may destroy this object
|
||||
RefCount<Command> tmp(m_command);
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
@param button the button number
|
||||
@param time the time stamp
|
||||
*/
|
||||
virtual void click(int button, int time);
|
||||
virtual void click(int button, int time, unsigned int mods);
|
||||
/// must use this to show submenu to ensure consistency for object like window menu in ClientMenu (see Workspace.cc)
|
||||
virtual void showSubmenu();
|
||||
RefCount<Command> &command() { return m_command; }
|
||||
|
|
|
@ -52,7 +52,7 @@ void MultiButtonMenuItem::setCommand(int button, FbTk::RefCount<FbTk::Command> &
|
|||
m_button_exe[button - 1] = cmd;
|
||||
}
|
||||
|
||||
void MultiButtonMenuItem::click(int button, int time) {
|
||||
void MultiButtonMenuItem::click(int button, int time, unsigned int mods) {
|
||||
if (button <= 0 || button > static_cast<signed>(buttons()) || buttons() == 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
/// sets command to specified button
|
||||
void setCommand(int button, FbTk::RefCount<FbTk::Command> &cmd);
|
||||
/// executes command for the button click
|
||||
virtual void click(int button, int time);
|
||||
virtual void click(int button, int time, unsigned int mods);
|
||||
/// @return number of buttons this instance handles
|
||||
inline unsigned int buttons() const { return m_buttons; }
|
||||
|
||||
|
|
|
@ -39,13 +39,15 @@ public:
|
|||
FbTk::RefCount<FbTk::Command> &cmd):
|
||||
FbTk::MenuItem(label, cmd),
|
||||
m_focus_control(focus_control),
|
||||
m_focusmodel(model) { }
|
||||
m_focusmodel(model) {
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
|
||||
bool isEnabled() const { return m_focus_control.focusModel() != m_focusmodel; }
|
||||
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
m_focus_control.setFocusModel(m_focusmodel);
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -61,13 +63,15 @@ public:
|
|||
FbTk::RefCount<FbTk::Command> &cmd):
|
||||
FbTk::MenuItem(label, cmd),
|
||||
m_focus_control(focus_control),
|
||||
m_tabfocusmodel(model) { }
|
||||
m_tabfocusmodel(model) {
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
|
||||
bool isEnabled() const { return m_focus_control.tabFocusModel() != m_tabfocusmodel; }
|
||||
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
m_focus_control.setTabFocusModel(m_tabfocusmodel);
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -108,11 +108,12 @@ public:
|
|||
string mode,
|
||||
FbTk::RefCount<FbTk::Command> &cmd):
|
||||
FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) {
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
bool isEnabled() const { return m_handler.mode() != m_mode; }
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
m_handler.setMode(m_mode);
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -126,11 +127,12 @@ public:
|
|||
Container::Alignment mode,
|
||||
FbTk::RefCount<FbTk::Command> &cmd):
|
||||
FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) {
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
bool isEnabled() const { return m_handler.alignment() != m_mode; }
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
m_handler.setAlignment(m_mode);
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
static int last_time = -201;
|
||||
int inc_val = 1;
|
||||
// check double click
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
// update label
|
||||
updateLabel();
|
||||
// call other commands
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
|
||||
// show new value, which for us means forcing a full menu update
|
||||
// since the text is drawn onto the background!
|
||||
|
|
|
@ -50,9 +50,9 @@ public:
|
|||
FbTk::MenuItem(label), m_object(object), m_layernum(layernum) {}
|
||||
|
||||
bool isEnabled() const { return m_object->layerNumber() != m_layernum; }
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
m_object->moveToLayer(m_layernum);
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
FbTk::MenuItem(label),
|
||||
m_attrib(attrib) {
|
||||
setToggleItem(true);
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
|
||||
bool isSelected() const {
|
||||
|
@ -123,7 +124,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
// reconfigure only does stuff if the apps file has changed
|
||||
Remember::instance().reconfigure();
|
||||
if (WindowCmd<void>::window() != 0) {
|
||||
|
@ -134,7 +135,7 @@ public:
|
|||
}
|
||||
}
|
||||
Remember::instance().save();
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -181,12 +181,14 @@ public:
|
|||
FbTk::RefCount<FbTk::Command> &cmd):
|
||||
FbTk::MenuItem(label, cmd),
|
||||
m_screen(screen),
|
||||
m_place(place) { }
|
||||
m_place(place) {
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
|
||||
bool isEnabled() const { return m_screen.getTabPlacement() != m_place; }
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
m_screen.saveTabPlacement(m_place);
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
|
||||
|
||||
|
|
16
src/Slit.cc
16
src/Slit.cc
|
@ -184,6 +184,7 @@ public:
|
|||
setCommand(cmd);
|
||||
FbTk::MenuItem::setSelected(client.visible());
|
||||
setToggleItem(true);
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
const string &label() const {
|
||||
return m_client.matchName();
|
||||
|
@ -191,7 +192,7 @@ public:
|
|||
bool isSelected() const {
|
||||
return m_client.visible();
|
||||
}
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
if (button == 4 || button == 2) { // wheel up
|
||||
m_slit.clientUp(&m_client);
|
||||
} else if (button == 5 || button == 3) { // wheel down
|
||||
|
@ -199,7 +200,7 @@ public:
|
|||
} else {
|
||||
m_client.setVisible(!m_client.visible());
|
||||
FbTk::MenuItem::setSelected(m_client.visible());
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
@ -214,16 +215,17 @@ public:
|
|||
m_slit(slit),
|
||||
m_label(label) {
|
||||
setLabel(m_label); // update label
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
// toggle direction
|
||||
if (m_slit.direction() == Slit::HORIZONTAL)
|
||||
m_slit.setDirection(Slit::VERTICAL);
|
||||
else
|
||||
m_slit.setDirection(Slit::HORIZONTAL);
|
||||
setLabel(m_label);
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
|
||||
void setLabel(const FbTk::FbString &label) {
|
||||
|
@ -245,12 +247,12 @@ class PlaceSlitMenuItem: public FbTk::MenuItem {
|
|||
public:
|
||||
PlaceSlitMenuItem(const FbTk::FbString &label, Slit &slit, Slit::Placement place, FbTk::RefCount<FbTk::Command> &cmd):
|
||||
FbTk::MenuItem(label, cmd), m_slit(slit), m_place(place) {
|
||||
|
||||
setCloseOnClick(false);
|
||||
}
|
||||
bool isEnabled() const { return m_slit.placement() != m_place; }
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
m_slit.setPlacement(m_place);
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
private:
|
||||
Slit &m_slit;
|
||||
|
|
|
@ -48,9 +48,9 @@ public:
|
|||
FbTk::MenuItem(label), m_object(object), m_headnum(headnum) {}
|
||||
|
||||
bool isEnabled() const { return m_object.getOnHead() != m_headnum; }
|
||||
void click(int button, int time) {
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
m_object.saveOnHead(m_headnum);
|
||||
FbTk::MenuItem::click(button, time);
|
||||
FbTk::MenuItem::click(button, time, mods);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue