From: Olivier Andrieu MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: <17706.41325.334205.592636 at karryall.dnsalias.org> Date: Mon, 9 Oct 2006 21:22:21 +0200 To: "Dmitry Bely" Cc: lablgtk at math.nagoya-u.ac.jp Subject: Re: Button accelerators In-Reply-To: <90823c940610091016i2ec702c6i8085fa434cb6a82e at mail.gmail.com> References: <90823c940610091016i2ec702c6i8085fa434cb6a82e at mail.gmail.com> Content-Type: text/plain; charset=us-ascii Content-Length: 852 Dmitry Bely [Monday 9 October 2006] : > > I have a dialog with OK and Cancel buttons: > > let dialog = GWindow.dialog > () in > ... > dialog#add_button_stock `OK `OK ; > dialog#add_button_stock `CANCEL `CANCEL ; > > match dialog#run () with > `OK -> ... > | `DELETE_EVENT | `CANCEL -> ... > > 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 `---- 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) `---- -- Olivier