[Lablgtk] Gdk.cursor / Gtk.Window type error

Erik de Castro Lopo mle+ocaml at mega-nerd.com
Tue Dec 2 03:40:33 CET 2008


Jacques GARRIGUE wrote:

> You just forgot the parentheses around (win:Gdk.window)
> Without them, this does not specify the type of win, but the return
> type of the function. Hence the error.

I think the lack of parentheses was actually a debugging artifact.
When I add them I get a function with a signature of:

    val create_null_cursor : Gdk.window -> Gdk.cursor

but then I run into trouble when I tried use it. If I replaced this
working code:

    let cursor = Gdk.Cursor.create `PLUS in
    Gdk.Window.set_cursor win#misc#window cursor ;

with:

    let cursor = create_null_cursor win in
    Gdk.Window.set_cursor win#misc#window cursor ;

I got the following error:

    This expression has type GWindow.window but is here used with type
      Gdk.window = [ `drawable | `gdkwindow ] Gobject.obj

Changing the above to this:

    let cursor = create_null_cursor win#misc#window in
    Gdk.Window.set_cursor win#misc#window cursor ;

solved the problem. The fact that I don't use Ocaml's object system
very often made this one a little difficult for me to debug.

Thanks for your help Jacques.

Cheers,
Erik
-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Microsoft treats security vulnerabilities as public relations
problems."  -- Bruce Schneier

_______________________________________________
Lablgtk mailing list
Lablgtk at yquem.inria.fr
http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk



More information about the Lablgtk-list mailing list