Fixes for MenuButton including stay depressed while menu is shown
This commit is contained in:
parent
e4445c52e7
commit
775ef6d809
2 changed files with 21 additions and 6 deletions
|
|
@ -36,14 +36,14 @@ const ArrowType arrowType = ARROW_DOWN;
|
||||||
const ShadowType shadowType = SHADOW_NONE;
|
const ShadowType shadowType = SHADOW_NONE;
|
||||||
|
|
||||||
MenuButton::MenuButton() :
|
MenuButton::MenuButton() :
|
||||||
Button(),
|
ToggleButton(),
|
||||||
arrow(arrowType, shadowType)
|
arrow(arrowType, shadowType)
|
||||||
{
|
{
|
||||||
setup_button();
|
setup_button();
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuButton::MenuButton(const StockID& stock_id) :
|
MenuButton::MenuButton(const StockID& stock_id) :
|
||||||
Button(),
|
ToggleButton(),
|
||||||
image(stock_id, ICON_SIZE_MENU),
|
image(stock_id, ICON_SIZE_MENU),
|
||||||
caption(),
|
caption(),
|
||||||
arrow(arrowType, shadowType)
|
arrow(arrowType, shadowType)
|
||||||
|
|
@ -58,8 +58,8 @@ MenuButton::MenuButton(const StockID& stock_id) :
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuButton::MenuButton(const Glib::ustring& label, bool mnemonic) :
|
MenuButton::MenuButton(const Glib::ustring& label, bool mnemonic) :
|
||||||
Button(),
|
ToggleButton(),
|
||||||
caption(label),
|
caption(label, mnemonic),
|
||||||
arrow(arrowType, shadowType)
|
arrow(arrowType, shadowType)
|
||||||
{
|
{
|
||||||
setup_button();
|
setup_button();
|
||||||
|
|
@ -76,11 +76,15 @@ MenuButton::popup()
|
||||||
{
|
{
|
||||||
menu.popup( mem_fun(this, &MenuButton::on_menu_position),
|
menu.popup( mem_fun(this, &MenuButton::on_menu_position),
|
||||||
0, gtk_get_current_event_time());
|
0, gtk_get_current_event_time());
|
||||||
|
set_active();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MenuButton::setup_button()
|
MenuButton::setup_button()
|
||||||
{
|
{
|
||||||
|
menu.signal_deactivate().connect(mem_fun(
|
||||||
|
this, &MenuButton::on_menu_deactivated));
|
||||||
|
|
||||||
arrow.set(ARROW_DOWN, SHADOW_NONE);
|
arrow.set(ARROW_DOWN, SHADOW_NONE);
|
||||||
|
|
||||||
hBox.pack_start(caption, PACK_EXPAND_WIDGET, CaptionPadding);
|
hBox.pack_start(caption, PACK_EXPAND_WIDGET, CaptionPadding);
|
||||||
|
|
@ -96,6 +100,12 @@ MenuButton::on_pressed()
|
||||||
popup();
|
popup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MenuButton::on_menu_deactivated()
|
||||||
|
{
|
||||||
|
set_active(false);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MenuButton::on_menu_position(int& x, int& y, bool& push_in)
|
MenuButton::on_menu_position(int& x, int& y, bool& push_in)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace widgets {
|
||||||
/**
|
/**
|
||||||
* A button that display a menu when clicked on.
|
* A button that display a menu when clicked on.
|
||||||
**/
|
**/
|
||||||
class MenuButton : public Gtk::Button
|
class MenuButton : public Gtk::ToggleButton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -86,7 +86,12 @@ protected:
|
||||||
/**
|
/**
|
||||||
* An event handler for when the button is pressed.
|
* An event handler for when the button is pressed.
|
||||||
**/
|
**/
|
||||||
virtual void on_pressed();
|
void on_pressed();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event handler for when the menu is closed.
|
||||||
|
**/
|
||||||
|
void on_menu_deactivated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue