我的最终目标是有一个处理程序,如果我按下#"1"
之类的键,它会做一些事情
我一直在阅读R3视图-事件处理文档,并试图在R3视图中运行代码,但没有得到任何结果。这是我复制的处理程序:
my-handler: [
name: 'my-handler
priority: 50
handler: func [event] [
print ["event:" event/type event/offset]
if switch event/type [
close [true]
key [event/key = escape]
] [
unhandle-events self
unview event/window
quit
]
show event/window
none
]
]
我尝试了两种方法来运行事件处理程序,但都没有结果:
handle-events my-handler
view layout [button]
和
view/options layout [button] [handler: my-handler]
我不知道该怎么办,有人能给我指明正确的方向吗?
以下是我尝试为密钥制作一个处理程序:
view/options [button] [
handler: [
name: 'my-handler
priority: 50
handler: func [event] [
if (event/key = #"1") [print "hi"]
]
]
]
据我所知,它没有任何作用。。。
这应该适用于已发布的saphirion r3 gui,但非常粗糙。
load-gui
ending: :halt ; :quit
base-handler: context [ ; we overwrite the default
do-event: func [event] [
; print "(Missing event handler)"
if switch event/type [
key [ ; this we add
; if event/key = #"1" [print "hi"]
escape = probe event/key
]
close [ true]
] [
unhandle-events self
unview event/window
ending
]
event
]
win-gob: none
status: 'made
name: 'no-name
priority: 0
about: "Main template for VIEW event handlers."
]
view/options [button] [handler: [] ]; this is not correct, so the base-handler is used