I'm making a Rebol 3 extension that has GUI events. For now, I manage this using synchronous callbacks so each time an event happens like a mouse move, the C extension calls the Rebol callback function. But I'd like to manage this using REBEVT and RL->event.
Here is a code sample:
case SDL_MOUSEMOTION:
Add_Event_XY(
RootGob, 2, (event.motion.x + (event.motion.y << 16)), EVT_MOVE
);
/*
cbi.obj = CBI_SDL_MOUSEMOTION.obj;
cbi.word = CBI_SDL_MOUSEMOTION.word;
RXI_COUNT(args) = 1;
RXI_TYPE(args, 1) = RXT_PAIR;
args[1].pair.x = event.motion.x;
args[1].pair.y = event.motion.y;
n = RL_CALLBACK(&cbi);
if(n == 0) {RL_PRINT("%s\n", "callback error");}
*/
break;
But then when I do a wait in Rebol, I get:
>> wait 1
** Script error: wake-up does not allow none! for its port argument
** Where: loop -apply- wait
** Near: loop 8 [
unless event: take sport/state [break]
port...
How to make the port not null?
After some searches in R3 code, I found that I had to initialize as below:
system/view/event-port: open event://
Now it works! (with R3 mainline)