Re: problems with accelerators in menu



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

> Hi there!
> 
> I've wrote a menubar with Gtk::Action, something like this:
> 
> 	 refActionGroup->add(Gtk::Action::create("Foo",
>                                               Gtk::Stock::YES,
> 	                                         "_Foo"),
> 	                     sigc::mem_fun(*this,
>                                         &Window::on_foo));
> 
> 	 refActionGroup->add(Gtk::Action::create("Bar",
>                                                Gtk::Stock::NO,
> 	                                         "_Bar"),
>                               sigc::mem_fun(*this,
>                                             &Window::on_bar));
> 
> 	/* uimanager settings */
> 
> 	pFoo = refUIManager->get_widget("/Where/Is/Foo");
> 	pBar = refUIManager->get_widget("/Where/Is/Bar");
> 	
> 	// so:
> 	
> 	refAccel = (refUIManager->get_accel_group());
> 	add_accel_group(refAccel);
> 
> 	pFoo->add_accelerator("activate", refAccel,
> 	                      'R', Gdk::CONTROL_MASK,
>                             Gtk::ACCEL_VISIBLE);
> 
> 	pBar->add_accelerator("activate", refAccel,
> 	                      'R',  Gdk::SHIFT_MASK | Gdk::CONTROL_MASK,
>                            Gtk::ACCEL_VISIBLE);
> 	
> But I've two problems:
> 
> 1) pBar accelerator does not work.
> 2) The menu does not show "Ctr+R' and 'Shift+Ctrl+R' labels
> 
> What's wrong with that?
> 
> Thanks in advance,
> 
> s.
> 
> 
> 
> 
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list

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));
 
I don't know why but It doesn't work for toolbar items!
-- 
Siavash Safi <siavash safi gmail com>



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