To: awolfing at yahoo.com Cc: lablgtk at kaba.or.jp Subject: Re: about glade | lablgtk2 |event In-Reply-To: <20030515074849.65181.qmail at web13601.mail.yahoo.com> References: <20030515074849.65181.qmail at web13601.mail.yahoo.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030516161901W.garrigue at kurims.kyoto-u.ac.jp> Date: Fri, 16 May 2003 16:19:01 +0900 From: Jacques Garrigue Lines: 27 From: awolfing > but i have a question about event: > first i define a signal for a entry > (on_test_entry_key_press_event). > then on my main.ml,i defined like this: > ... > method do ()=... > initializer > self#bind ~name"on_test_entry_key_press_event" > ~callback:self#do > ... > > how can i know which key is pressed? You cannot do it this way: callbacks defined in glade only take unit, as shown in the type of the method bind. To be exact, internally it calls the function bind_handler, which lets you connect an arbitrary handler, but this is not a good idea to use it, as no type check is done. The right way to do it is to use the #event#connect#key_press method: self#entry1#event#connect#key_press ~callback: (fun ev -> let kv = GdkEvent.Key.keyval ev in ...; true) Jacques