【问题标题】:Making a Hostkit Event in Rebol3在 Rebol3 中创建 Hostkit 事件
【发布时间】:2015-05-28 00:22:17
【问题描述】:

我正在制作一个具有 GUI 事件的 Rebol 3 扩展。 目前,我使用同步回调来管理它,因此每次发生鼠标移动等事件时,C 扩展都会调用 Rebol 回调函数。 但我想使用 REBEVT 和 RL->event 来管理它。

这是一个代码示例:

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;

但是当我在 Rebol 中等待时,我得到:

>> 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...

如何让端口不为空?

【问题讨论】:

  • 在不知道答案的情况下,我可以指点你作为一个好人问的世新:"Avoiding recursion when reading/writing a port synchronously?"。无论如何,他在这个领域工作过。如果您运行的不是 Atronix 版本的 Rebol,您可以try it 看看它的行为是否有所不同。
  • 希望世新能过来看看!我尝试了“主线”版本和 Saphirion 版本:它有效。我尝试了 Atronix 版本,但它崩溃了:仍然需要调查原因。
  • 如果是这种情况,并且它仅在 Atronix 构建中,那么听起来您应该 file a bug report。他在那里比在这里更有可能看到它。
  • 当然,我需要先做进一步的测试,然后我会归档。

标签: sdl rebol rebol3


【解决方案1】:

在R3代码中搜索了一番后,我发现我必须初始化如下:

system/view/event-port: open event://

现在可以了! (带 R3 主线)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-09
    • 2016-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多