Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Event datatype

From: carl:cybercraft at: 30-Aug-2002 21:13

On 30-Aug-02, G. Scott Jones wrote:
> Hi, Carl, > That is some neat stuff that Cyphre uncovered. I wasn't able to take > it any further than he did.
I'd discovered that you could get at event/1 etc, but not got any futher either.
> Previously, I developed a way to screen events to a specific widget, > like used to restrict key stroke types. It sounds like you need > something at the more global level. I, too, have found no "easy" way > to do this, but I did expand a concept developed by Brett last year. > Here is an example to play with: > REBOL [] > query-before-passing-on: func [face event][ > switch/default event/type [ > close [ > either not within? system/view/focal-face/offset > win-offset? f f/size [ > print "no way can you exit unless focus is on first > field" > return none > ][ > remove-event-func :query-before-passing-on > event > ] > ] > key [ > either not within? system/view/focal-face/offset > win-offset? f f/size [ > print "only taking key presses in first field" > return none > ][ > event > ] > ] > ] [event] > ] > view layout [ > text "Close button only works while focus is on first field" > text "Key presses only accepted in first field" > f: field > field > do [insert-event-func :query-before-passing-on ] > ] > This may happen to be just the sort of convoluted thing you hoped to > avoid, but it (mostly) works. Maybe with a little tuning it could > work well! The key to this structure is that it keeps passing the > event on, if the chain is not interrupted. What I haven't been able > to do is to alter the event and then pass it on.
That's more or less my problem, and I've got about as far as you have. I did think of something today though - copy those 8 events Cyphre detailed to a block named 'event and send that to the function. This worked in my case as the function receiving it doesn't check if it's an event! datatype. It works because the function's just working on event/key, and doesn't care if event is an event or block datatype. I don't trust using this though as the function's a long one and I don't fully understand it. (; However, if you did understand the function fully and it doesn't actually need to know event is an event!, then I can't see any reason why you shouldn't do this. ie... e: event event: reduce [e/1 e/2 e/3 e/4 e/5 e/6 e/7 e/8] Other than checking if an event datatype really is an event datatype, is there anything else you can do with one other than referencing their values? -- Carl Read