[Gambas-devel] Event design choice
Benoît Minisini
gambas at ...1...
Tue May 8 17:38:43 CEST 2012
Le 08/05/2012 17:02, tobi a écrit :
>
> Sounds like it complicates things even more ;) Actually a good idea, for both parties. Although, it
> intermixes Window and Screen class again... Of course, this is better than raising with a default
> "Window" event name... I don't know if I'm content with that, I hoped to get rid of that focused
> Window but it simplified that much. However, good to learn new things every day (GB.CanRaise()), but
> I have to set up this idea a little further: I watch the input queue associated with a screen using
> my (not already commited) input module which then would utilise the @focused window and something
> like an @active screen (for now, there is only one auto-creatable screen but that will change as
> needed). The input module first checks if the @focused window has an event handler (of course it
> has, since I will raise an error if a Window.SetFocus() is done on a window which has no event name
> - with that in mind, it sounds not that confusing anymore!) and if it is NULL, the screen raises the
> event.
> OK, convinced, I have to rewrite the documentation anyway :)
>
> Great idea, actually.
>
> Regards,
> Tobi
>
Hi,
In revision #4721, you have two new interpreter APIs:
GB.Signal.Register:
GB_SIGNAL_CALLBACK *GB.Signal.Register(int signum, void (*callback)(int,
intptr_t), intptr_t data)
This function asks Gambas to call the 'callback' function each time the
'signum' signal is received. 'data' is a pointer that will be passed
as-is to the 'callback' function as second argument. The first one being
the signal number.
A pointer is returned, that you must use to unregister the signal
callback once you are done with it.
GB.Signal.Unregister:
void GB.Signal.Unregister(GB_SIGNAL_CALLBACK *callback);
The callback is called in the context of the event loop, not in the
context of the signal handler. So you can do what you want in these
callbacks: raise events for example.
Being the first one who will use that API, you will tell me if it works!
Regards,
--
Benoît Minisini
More information about the Devel
mailing list