Gtk spin button
Edgar Friendly <[email protected]>
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
(sorry for missent 1st email)
I'm making a simple dialog box [1], and I want w#run to return `OK (the
default response) when the user presses <enter> in the spin-box.
I find the function gtk_entry_set_activates_default () in the GTK
documentation, but it seems that spin_button inherits from widget
instead of entry in lablgtk2 (2.10.0). Did someone intend this
mis-alignment of inheritance? I feel hesitant at hacking things, and
worry that maybe there's an incompatibility somewhere reflected here.
Thanks,
E.
let go_to_page_dialog () =
let w = GWindow.dialog ~parent:window ~title:"Go to page" ~modal:true
~position:`CENTER () in
ignore (GMisc.label ~text:"Page: " ~packing:w#vbox#add ());
let sb = GEdit.spin_button ~packing:w#vbox#add ~digits:0 ~numeric:true
() in
sb#adjustment#set_bounds ~lower:0. ~upper:(float (max_index ()))
~step_incr:1. (); sb#set_value (float (cur_page ()));
sb#set_activates_default true;
w#add_button_stock `OK `OK;
w#add_button_stock `CANCEL `CANCEL;
w#set_default_response `OK;
let on_ok () = new_pos (group_pages ~seed:sb#value_as_int
~forward:true); w#destroy () in
match w#run () with
| `DELETE_EVENT | `CANCEL -> w#destroy ()
| `OK -> on_ok ()