MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16486.17988.561211.516751 at soggy.deldotd.com> Date: Sat, 27 Mar 2004 19:28:04 -0800 To: Olivier Andrieu Cc: lablgtk at kaba.or.jp Subject: Re: event variant types In-Reply-To: <16483.63571.455639.187324 at akasha.ijm.jussieu.fr> References: <16482.33127.497203.821118 at soggy.deldotd.com> <20040325165247V.garrigue@kurims.kyoto-u.ac.jp> <16483.50834.898498.682875@soggy.deldotd.com> <16483.63571.455639.187324@akasha.ijm.jussieu.fr> From: briand at aracnet.com I've created a simpler test program. here is some relevant code: let handle_event event = match GdkEvent.get_type event with (* #GdkEvent.Button.types -> handle_button_event event; true *) `KEY_PRESS -> Printf.printf "key press\n"; true | `MOTION_NOTIFY -> Printf.printf "motion\n"; true | _ -> false ... area#event#add [`KEY_PRESS]; (* Event capture of keypresses *) let signal_id = w#event#connect#key_press ~callback: begin fun ev -> let key = GdkEvent.Key.keyval ev in if key = GdkKeysyms._Escape then w#destroy (); handle_event ev; true end; in Here is the error message : This expression has type GdkEvent.Key.t = [ `KEY_PRESS | `KEY_RELEASE ] Gdk.event but is here used with type [> `KEY_PRESS | `MOTION_NOTIFY ] Gdk.event The first variant type does not allow tag(s) `MOTION_NOTIFY This error occurs at the line "handle_event ev". It still seems that this points to a flaw in the types representing the events. Binding the event causes the types allowed to be restricted and so it is no longer possible to call the same proc with different events. Or at least this is my interpretation of what is happening... Brian