Re: [Vala] Gdk event handler cast mystery



Gdk.Event* are structs.  Casting the Gdk.Event class to one of them
doesn't work.  Use the relevant Gdk.Event member instead:

        Gdk.EventButton eb = event.button;


-Evan


On Wed, 2013-10-30 at 15:33 +0200, Donn Ingle wrote:
Hello; partial code:
--
private bool handle_events(Gdk.Event event) {
  if (event.type == Gdk.EventType.BUTTON_PRESS)
  {
    Gdk.EventButton eb = (Gdk.EventButton) event;
    //Now I can use "eb" for e.g. eb.state or eb.x
    ... etc.
--

When I try to compile, I get an error. It seems to be an error in the
c compilation:
--
error: conversion to non-scalar type requested
eb = (GdkEventButton) _tmp2_;
^
--

I took the idea from the GDK docs
(https://developer.gnome.org/gdk3/stable/gdk3-Event-Structures.html#GdkEvent)
where they speak of casting:
--
GdkEvent *event;
gdouble x;

x = ((GdkEventButton*)event)->x;
--

Any idea what I'm doing wrong in Vala?

\d
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]