[REBOL] Re: Question about events....
From: arolls:bigpond:au at: 15-Jun-2001 4:55
See below for a program that catches 'time
events and all 'down events in all sub-faces
of a text-list.
> Aviles, Javier
> Sent: Wednesday, 13 June, 2001 6:23 AM
> To: ['rebol-list--rebol--com']
> Subject: [REBOL] Question about events....
> based in the description of the engage function:
>
> The engage function is called whenever
> any event other than a REDRAW or an
> OVER occurs for a face. It handles mouse
> click events, keyboard input, timers,
> and other types of events.
> I would like to know, if it's possible
> to handle diferents events in the same face,
> and if that is possible an example for it....
> I want that a text-list be updated each 30
> seconds, and also when the down action ocurrs
> a process be executed....
> any idea?
> thanks for your help....
> Javier H. Avilés Avila.
I haven't discovered how to see which face
was clicked on yet. Maybe someone can help
here (if it is necessary for you to know
which sub-face was clicked 'down on).
Anton.
-- Start program -- (watch for line wrap) --------
rebol [
Title: "Text-List Events"
File: %text-list-events.r
Date: 15-Jun-2001
Version: 1.0.0
Needs: [view]
Author: "Anton Rolls"
Language: 'English
Purpose: {
Demonstrate catching 'time and 'down events
in a text-list
}
ToDo: {
- How to find the face that was clicked on?
}
History: [
1.0.0 [15-Jun-2001 {First version} "Anton"]
]
Notes: {
See Docs: http://www.rebol.com/how-to/feel.html
To find out how to get the original text-list/feel:
view layout [
t: text-list
data ["A"]
[probe t/feel probe t/iter/feel]
]
probe first t == interesting words to look at.
probe get-style 'text-list == mmm yum miam
Original question was on rebol-list email,
on 13-Jun-2001, by Javier Aviles.
}
]
view/new center-face layout [
t: text-list
rate 1 ; fire 'time action once per second
data ["A" "B" "C"]
[] ; action block - empty.
; it is necessary because otherwise
; it doesn't work.
]
t/feel: make t/feel [
; just modify the functions you need to here.
; we need to modify 'detect because we need
; to catch events for *sub-faces* of the text-list.
; (That is the individual face used for each
; item)
detect: func [face event][
if event/type = 'down [
print "detect: down"
]
event ; let the event go through to the sub-face
]
engage: func [face action event][
switch action [
time [
if not face/state [face/blinker: not face/blinker]
print "engage: time"
; count to 30 here
]
down [face/state: on]
alt-down [face/state: on]
up [if face/state [do-face face none] face/state: off]
alt-up [if face/state [do-face-alt face none] face/state: off]
over [face/state: on]
away [face/state: off]
]
cue face action
show face
]
]
wait none
-- End Program --------------------