Date: Thu, 11 Aug 2005 11:15:39 -0300 From: romildo at uber.com.br To: lablgtk at math.nagoya-u.ac.jp Subject: Re: [newbie] Setting a callback Message-ID: <20050811141539.GA17628 at malaquias> References: <20050811124512.GA15090 at malaquias> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050811124512.GA15090 at malaquias> On Thu, Aug 11, 2005 at 09:45:12AM -0300, romildo at uber.com.br wrote: > Hello again. > > How can I set a callback for focus_out_event in a text entry > widget? I have found the solution myself. > let check_entry entry () = The last argument of the callback should be the focus event, which is irrelevant here. So the above line should be: let check_entry entry _ = > let x = int_of_string entry#text in > print_int x; > print_newline () And this callback should return false: false > > let main () = > let window = GWindow.window ~title:"Test" ~border_width:10 () in > let box = GPack.hbox ~spacing:10 ~packing:window#add () in > let label = GMisc.label ~text:"Value" ~xalign:0.0 ~packing:box#pack () in > let entry = GEdit.entry ~text:"21" ~packing:box#pack () in > let button = GButton.button ~label:"Quit" ~packing:box#pack () in > entry#connect#focus_out_event ~callback:(check_entry entry); The above line should be: entry#event#connect#focus_out ~callback:(check_entry entry); > button#connect#clicked ~callback:GMain.Main.quit; > window#connect#destroy ~callback:GMain.Main.quit; > window#show (); > GMain.Main.main () > > let _ = > Printexc.print main () Romildo