Delivered-To: lablgtk at yquem.inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:date:to:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; bh=HHTgc5hMCCmD5p3nTBIKpMpY+MAeskMdHngBmEFCYRM=; b=OLn4mXxQwoFyE9WMHgzjO+8lvtcotiLGCpQOLuKFDAN4+C00a08CQIwPcNSwnzfvJJRcvZfLwxximN1qSB1bq1fbsTpCUWTAsdm0fIPXFCHXD8wG+z+cOl56ZTzSJZ+v0oWgeBuq6C85hkszNML0xaFG1PBGjXhMSofderdY+Bk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:to:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; b=E35dgETZxqllYOL2f8QsOn6nhjg98rcrSBfJJAB3JZDH2xAS+T3y0ilRI/uvES7HGU/m2hGoqvJF0Ej+QgG6Vf7Y7rxqzLZANomw6y7pXY7LU34BN/0gbDEVeHaa+4JBmL/IWSmgNVJWVPzepEHXshHuvApg/Raz4iwg3UTntVo= Date: Fri, 25 Jan 2008 10:58:50 +0100 To: lablgtk at yquem.inria.fr Subject: Re: [Lablgtk] Gtk spin button Message-ID: <20080125093449.GA14983 at localhost> Mail-Followup-To: Julien Moutinho , lablgtk@yquem.inria.fr References: <47996A67.2070509 at gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <47996A67.2070509 at gmail.com> From: Julien Moutinho Content-Type: text/plain; charset=utf-8 Content-Length: 1715 On Thu, Jan 24, 2008 at 10:49:43PM -0600, Edgar Friendly wrote: > (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 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. Indeed, perhaps a [method entry = new GEdit.entry obj] would be welcome inside [GEdit.spin_button]. Since http://library.gnome.org/devel/gtk/stable/GtkSpinButton.html says that: "[entry] is the GtkEntry part of the GtkSpinButton widget, and can be used accordingly." Still, as a workaround, a manual cast is possible with [GtkEdit.Entry.cast]: let _ = let w = GWindow.dialog () ~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 let entry = new GEdit.entry (GtkEdit.Entry.cast sb#as_widget) in entry#set_activates_default true; w#add_button_stock `OK `OK; w#add_button_stock `CANCEL `CANCEL; w#set_default_response `OK; let on_ok () = print_endline (string_of_int sb#digits); w#destroy () in match w#run () with | `DELETE_EVENT | `CANCEL -> w#destroy () | `OK -> on_ok () HTH. _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk