Button accelerators

Olivier Andrieu oandrieu at nerim.net
Mon Oct 9 22:14:39 CEST 2006


 Dmitry Bely [Tuesday 10 October 2006] :
 >
 > On 10/9/06, Olivier Andrieu <oandrieu at nerim.net> wrote:
 > >  > I have a dialog with OK and Cancel buttons:
 > >  >
 > >  > Now I would like to add Enter/ESC accelerators to Ok and
 > >  > Cancel buttons respectively. How to do that?
 > >
 > > For enter, it's easy :
 > > ,----
 > > | dialog#set_default_response `OK
 > > `----
 > 
 > Well, if GEdit.entry is active this does not work.

Hmm

 > > For esc, it's a bit more complicated. It should work out of the box on
 > > a C gtk+ app, but not with lablgtk. It should be fixed in GTK+ 2.10
 > > (it's bug #101293 in the GNOME bugzilla) but for previous versions you
 > > need to manually connect a signal :
 > > ,----
 > > | dialog#connect#close (fun () -> d#response `CANCEL)
 > > `----
 > 
 > This works, thank you, but how to get the same for Enter?

You could use the "activates-default" property of GEdit.entry:
  http://developer.gnome.org/doc/API/2.0/gtk/GtkEntry.html#GtkEntry--activates-default

or connect the "activate" signal of the entry to generate the OK
response.

-- 
   Olivier




More information about the Lablgtk-list mailing list