[REBOL] Re: Interrupting an action
From: agem:crosswinds at: 15-Jul-2001 15:11
RE: [REBOL] Interrupting an action
[Sanghabum--aol--com] wrote:
> Hi all,
>
> If I've got a VID action facet that takes a long time, how can I provide the
> user with some way of aborting the action?
>
> I've tried polling the Console as per the KBHIT thread of some weeks ago. But
> that takes input from the Console, not the layout.
>
> So what code can I use to replace the comment below?
>
> > unview/all
> view layout [
> Button "long wait"
> [
> ResultField/Text: "Working" show resultField
> loop 100
> [ wait 1
> ;;check for escape key/cancel button
> ] ;loop
> ResultField/Text: "Finished" show resultField
> ];action
> resultField: info
> ];layout
> >
[rebol []
unview/all
stop: false
view layout [
Button "long wait"
[
ResultField/Text: "Working" show resultField
i: 0
forever
[
i: i + 1
;only all 100 steps os-call
if i // 100 [
wait 0
if stop [break]
;some "work"
prin random "*?!#@+&()\"
]
]
ResultField/Text:
pick ["Interrupted" "Finished"] stop
show resultField
] ;action
button "stop" [
stop: true
] ;layout
resultField: info
]
]