Re: problems with accelerators in menu





Siavash Safi wrote:
On Sat, 02 Jun 2007 17:13:53 +0200
Sergio Perticone <g4ll0ws gmail com> wrote:

--8<-------------

Hi,

I found this function in Gtk::ActionGroup:
void 	add (const Glib::RefPtr<Action>& action, const AccelKey& accel_key, const Action::SlotActivate& slot)

So you should add menu items like this:
	refActionGroup->add (Gtk::Action::create("Foo", Gtk::Stock::YES, "_Foo"),
				Gtk::AccelKey ('r', Gdk::CONTROL_MASK, "<ui>/Where/Is/Foo"),
				sigc::mem_fun (*this, &Window::on_foo));

Good tip!
Anyway I understand why 'R', Gdk::SHIFT_MASK | Gdk::CONTROL_MASK did not work: that accel was catched by beryl... what a shame.

Furthermore Gtk::AccelKey seems to accept ustring for accel, so we can write:

refActionGroup->add(Gtk::Action::create("Foo", Gtk::Stock::YES, "_Foo"),
                            Gtk::AccelKey("<control> r"),
                            sigc::mem_fun(*this, &Window::on_foo))

More readable and without the widget path, it works.

I don't know why but It doesn't work for toolbar items!

Uhm, pheraps toolitems cannot have an accel key. I don't know.

Thanks,

s.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]