windows events
[1/6] from: ammoncooke::yahoo at: 3-Oct-2001 16:56
Hi,
Just finished the Event Handler howto...
The last line states, "It is better to use the INSERT-EVENT-FUNC function to set window
event handlers. This function allows multiple handlers for each window. It will be discussed
separately."
Is this seperate enough for someone to discuss it with me? ;)
I tried this:
insert-event-func [redraw: func[f a p] [
wrkspc/size: (mn/size - 140x75)
show wrkspc
show bldr-cr
]]
it returned this:
** Script Error: evt-func is missing its p argument
** Where: wake-event
** Near: return either evt-func [event] [none]
I have also tried several other things, & looked at all the source I could find.
Thanks!!
Ammon
[2/6] from: cyphre:volny:cz at: 4-Oct-2001 11:20
Hello Ammon,
try this example:
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!
Regards,
Cyphre
----- Original Message -----
From: "Ammon Cooke" <[ammoncooke--yahoo--com]>
To: <[rebol-list--rebol--com]>
Sent: Thursday, October 04, 2001 1:56 AM
Subject: [REBOL] windows events
> Hi,
>
> Just finished the Event Handler howto...
>
> The last line states, "It is better to use the INSERT-EVENT-FUNC
function to set window event handlers. This function allows multiple
handlers for each window. It will be discussed separately."
[3/6] from: greggirwin:starband at: 4-Oct-2001 11:08
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:
>> source insert-event-func
insert-event-func: func [
{Add a function to monitor global events. Return the func.}
funct [block! function!] "A function or a function body block"
][
if block? :funct [funct: func [face event] funct]
insert system/view/screen-face/feel/event-funcs :funct
:funct
]
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.
Thanks!
--Gregg
[4/6] from: ammoncooke::yahoo::com at: 4-Oct-2001 19:26
You're awesome! Now the question, "What's this little bug?"
insert-event-func func [face event][
if equal? to-string event/type "resize"[
wrkspc/size: (mn/size - 140x50)
bldr-cr/size: wrkspc/size
bldr-cr-dt/size: (wrkspc/size - 30x70)
bldr-cr-fls/size/x: (wrkspc/size/x - 230)
bldr-cr-cls/offset/x: (wrkspc/size/x - 22)
bldr-cr-dt-sly/offset/x: (bldr-cr-dt/size/x + bldr-cr-dt/offset/x)
bldr-cr-dt-sly/size/y: bldr-cr-dt/size/y
bldr-cr-dt-slx/offset/y: (bldr-cr-dt/size/y + bldr-cr-dt/offset/y)
bldr-cr-dt-slx/size/x: bldr-cr-dt/size/x
show mn
]
return event
]
this code acts exactly as expected except that bldr-cr-dt-slx does not
resize when the window is resized in both directions. It does resize
properly when only the x dimension is changed. I only ask this because
bldr-cr-dt-sly resizes 100% properly. BTW bldr-cr-dt-slx, & bldr-cr-dt-sly
are sliders running on the x, y dimensions.
Thanks!!
Ammon
[5/6] from: greggirwin:starband at: 5-Oct-2001 11:11
Thanks Cyphre!
I'll dig into that ASAP.
--Gregg
[6/6] 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