[REBOL] Re: windows events
From: cyphre:volny:cz at: 5-Sep-2001 10:48
Hi Gregg,
----- Original Message -----
From: "Gregg Irwin" <[greggirwin--starband--net]>
To: <[rebol-list--rebol--com]>
Sent: Thursday, October 04, 2001 7:08 PM
Subject: [REBOL] Re: windows events
> Hi Cyphre,
>
> << insert-event-func func [face event][probe event/type return event]
> view layout [button "hello"]
>
> I hope this explains all the magic ;)
> Don't forget to always 'return event' else your rebol will hangs! >>
>
> That's great! Now, you also need to use remove-event-func, right? Are
there
> any good examples of how to use these effectively and robustly (
> inserting/removing/finding event functions) or using them in other than a
> global manner? For example, the source for insert-event-func looks like
> this:
>
try this:
my-func: func [f e][probe e/type return e]
view layout [
button 200x20 "insert my-func" [if not find
system/view/screen-face/feel/event-funcs :my-func [
insert-event-func :my-func
]
]
button 200x20 "remove my-func" [remove-event-func :my-func]
]
> Which shows them being inserted into
> system/view/screen-face/feel/event-funcs. Are there any known examples of
> using them with other faces? I didn't see any other feel items (from a
quick
> check) that contained event-funcs.
>
As I know, these event-funcs are used for creating custom event handlers.
They are always on top of the event-tree(in the highest face - screen-face).
You can use it for manging/filtering events that are comming into the active
screen-face(window). Here is example(not so much useful but could explain
the possibilities of the event-handlers) of little keyboard handler and
event filter:
-----------------------------------------------------------------------
face-over: none
kb-handler: func [f e][
switch e/key [
#"^[" [
remove-event-func :kb-handler
remove-event-func :event-filter
unview f
return none
]
]
if e/key [b/text: e/key show b]
return e
]
event-filter: func [f e][
if all [e/type = 'down face-over = "forbidden button"][
return none
]
face-over: none
return e
]
insert-event-func :kb-handler
insert-event-func :event-filter
view layout [
across
text "pressed key:"
b: banner 80x30 ""
below
button "normal button" []
button "filtered button" with [
feel: make feel [
detect: func [f e][
if e/type = 'move [face-over: "forbidden button"]
]
]
]
text "press 'ESC' key to exit"
]
----------------------------------------------------------------
regards,
Cyphre