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;
|
||||
|
||||
MenuButton::MenuButton() :
|
||||
Button(),
|
||||
ToggleButton(),
|
||||
arrow(arrowType, shadowType)
|
||||
{
|
||||
setup_button();
|
||||
}
|
||||
|
||||
MenuButton::MenuButton(const StockID& stock_id) :
|
||||
Button(),
|
||||
ToggleButton(),
|
||||
image(stock_id, ICON_SIZE_MENU),
|
||||
caption(),
|
||||
arrow(arrowType, shadowType)
|
||||
|
|
@ -58,8 +58,8 @@ MenuButton::MenuButton(const StockID& stock_id) :
|
|||
}
|
||||
|
||||
MenuButton::MenuButton(const Glib::ustring& label, bool mnemonic) :
|
||||
Button(),
|
||||
caption(label),
|
||||
ToggleButton(),
|
||||
caption(label, mnemonic),
|
||||
arrow(arrowType, shadowType)
|
||||
{
|
||||
setup_button();
|
||||
|
|
@ -76,11 +76,15 @@ MenuButton::popup()
|
|||
{
|
||||
menu.popup( mem_fun(this, &MenuButton::on_menu_position),
|
||||
0, gtk_get_current_event_time());
|
||||
set_active();
|
||||
}
|
||||
|
||||
void
|
||||
MenuButton::setup_button()
|
||||
{
|
||||
menu.signal_deactivate().connect(mem_fun(
|
||||
this, &MenuButton::on_menu_deactivated));
|
||||
|
||||
arrow.set(ARROW_DOWN, SHADOW_NONE);
|
||||
|
||||
hBox.pack_start(caption, PACK_EXPAND_WIDGET, CaptionPadding);
|
||||
|
|
@ -96,6 +100,12 @@ MenuButton::on_pressed()
|
|||
popup();
|
||||
}
|
||||
|
||||
void
|
||||
MenuButton::on_menu_deactivated()
|
||||
{
|
||||
set_active(false);
|
||||
}
|
||||
|
||||
void
|
||||
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.
|
||||
**/
|
||||
class MenuButton : public Gtk::Button
|
||||
class MenuButton : public Gtk::ToggleButton
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
@ -86,7 +86,12 @@ protected:
|
|||
/**
|
||||
* 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:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue