Re: drawing area & events

Basile STARYNKEVITCH <[email protected]> Thu, 07 Jan 2010 22:09:20 +0100
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
Basile STARYNKEVITCH wrote:
> 
> let buttonfun bev =
>   let butnum = GdkEvent.Button.button bev
>   and x = (int_of_float (GdkEvent.Button.x bev))
>   and y = (int_of_float (GdkEvent.Button.x bev))
>   in
>     Printf.eprintf "buttonfun butnum=%d x=%d y=%d\n%!" butnum x y;
>     pointslist := (x,y)::!pointslist;
>     ()
> ;;

Sorry for the stupid mistake - a typo in the y line, which should of course be
   and y = (int_of_float (GdkEvent.Button.y bev))

So the function should be

let buttonfun bev =
   let butnum = GdkEvent.Button.button bev
   and x = (int_of_float (GdkEvent.Button.x bev))
   and y = (int_of_float (GdkEvent.Button.y bev))
   in
     Printf.eprintf "buttonfun butnum=%d x=%d y=%d\n%!" butnum x y;
     pointslist := (x,y)::!pointslist;
     ()
;;

> 
> For some reason, the mouse click coordinates are not correct in the 
> drawing area. I should make some conversion (how to do that)?

My fault!

However, I am still not getting any key event. Any idea?
   ignore (drawar#event#add [ `BUTTON_PRESS; `KEY_PRESS; `FOCUS]);
don't seems to work.


Regards

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***