Add API to set select item from ArdourDropdown
This fixes an issue with scroll-wheel control which uses `get_active()`. It work around an issue with gtkmm: const MenuItem* get_active () const void set_active (guint index) and MenuList::activate_item() not emitting activate_item().
This commit is contained in:
@@ -80,6 +80,22 @@ ArdourDropdown::on_button_press_event (GdkEventButton* ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ArdourDropdown::set_active (std::string const& text)
|
||||
{
|
||||
using namespace Menu_Helpers;
|
||||
const MenuList& items = _menu.items ();
|
||||
int c = 0;
|
||||
for (MenuList::const_iterator i = items.begin(); i != items.end(); ++i, ++c) {
|
||||
if (i->get_label() == text) {
|
||||
_menu.set_active(c);
|
||||
_menu.activate_item(*i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
set_text (text);
|
||||
}
|
||||
|
||||
bool
|
||||
ArdourDropdown::on_scroll_event (GdkEventScroll* ev)
|
||||
{
|
||||
|
||||
@@ -51,9 +51,10 @@ public:
|
||||
Gtk::Menu_Helpers::MenuList& items () { return _menu.items (); }
|
||||
|
||||
void append_text_item (std::string const& text);
|
||||
void set_active (std::string const& text);
|
||||
|
||||
protected:
|
||||
void default_text_handler (std::string const& text);
|
||||
void default_text_handler (std::string const&);
|
||||
|
||||
private:
|
||||
Gtk::Menu _menu;
|
||||
|
||||
Reference in New Issue
Block a user