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

Event datatype

 [1/11] from: carl::cybercraft::co::nz at: 29-Aug-2002 0:17


Is there any way to modify the event datatype? For instance, change the event/key value to something else? -- Carl Read

 [2/11] from: greggirwin:mindspring at: 28-Aug-2002 10:50


Hi Carl, << Is there any way to modify the event datatype? For instance, change the event/key value to something else? >> I tried briefly once, but couldn't do it. For my purposes (key-mapping) I just acted on the keys as they came in. --Gregg

 [3/11] from: gscottjones:mchsi at: 28-Aug-2002 14:42


From: "Carl Read"
> Is there any way to modify the event datatype? For instance, change > the event/key value to something else?
Hi, Carl, I was unsure what you were asking. After Gregg answered, I was sure that I was unsure. If you have not found your answer, can you give more detail, like are you looking to modify the event/key for a widget like "field"? --Scott Jones

 [4/11] from: petr:krenzelok:trz:cz at: 28-Aug-2002 20:37


Gregg Irwin wrote:
>Hi Carl, > ><< Is there any way to modify the event datatype? For instance, change >the event/key value to something else? >> > >I tried briefly once, but couldn't do it. For my purposes (key-mapping) I >just acted on the keys as they came in. > >--Gregg >
IIRC, Cyphre was able to catch and store events, and later replay them. But event itself seems to be a strange hybrid :-) I think that it was purpose to hide its internals. IIRC, it was also planned by RT one day we will be able to generate events ... btw - was anyone successfull in system:// port usage? Any code example? :-) -pekr-

 [5/11] from: greggirwin:mindspring at: 28-Aug-2002 15:08


Hi Petr, << btw - was anyone successfull in system:// port usage? Any code example? :-) >> I haven't found any docs on it, though I'd *love* to see something myself. --Gregg

 [6/11] from: carl:cybercraft at: 29-Aug-2002 20:53


On 29-Aug-02, G. Scott Jones wrote:
> From: "Carl Read" >> Is there any way to modify the event datatype? For instance, change >> the event/key value to something else? > Hi, Carl, > I was unsure what you were asking. After Gregg answered, I was sure > that I was unsure.
(:
> If you have not found your answer, can you give > more detail, like are you looking to modify the event/key for a > widget like "field"? --Scott Jones
Yes, something like that. I'm intercepting an event before it reaches a function that normally gets it so I can do some stuff first based on whatever the event is. I then pass it on to that function, or not if because of the event it doesn't need to be called. But that's the only choice I have - either send the event as is, or not send it. In some cases I'd like to be able to modify the key value in event and send that on, but it seems there's no way to do this. There's a convoluted way I can get around this, but it'd be so much simplier to just do something like... event/key: #"Z" event-function face event action It's not a show-stopper though... -- Carl Read

 [7/11] from: cyphre:seznam:cz at: 29-Aug-2002 11:58


Hi guys, Yes, I was experimenting with possibilities of event! datatype. Unfortunately, the event! datatype is a bit hardcoded,we could make its own events but we cannot modify them(or at least I havent found any way how to do it). The events have "invisible" behaviour ;-) for example see this console session:
>> my-event: make event! [] >> probe my-event >> events: copy []
== []
>> insert events my-event
== []
>> probe events
[] == []
>> length? events
== 1
>> type? events/1
== event!
>>
but the event looks inside ok:
>> my-event: make event! [] >> my-event/1 ;which means event/type
== down
>> my-event/2 ;which means event/key
== none
>> my-event/3 ;which means event/offset
== 0x0
>> my-event/4 ;which means event/time
== 0
>> my-event/5 ;which means event/shift
== false
>> my-event/6 ;which means event/control
== false
>> my-event/7 ;which means event/face
== none
>> my-event/8 ;which means event/double-click
== false unfortunately, when trying modify my custom event:
>> my-event: make event! [type: up key: #"k" offset: 10x10 time: 12345
shift: false control: false face: none double-click: false]
>> my-event/1
== down
>> my-event/2
== none
>> my-event/3
== 0x0
>> my-event/4
== 0
>> my-event/5
== false
>> my-event/6
== false
>> my-event/7
== none
>> my-event/8
== false
>>
or even:
>> my-event/1
== down
>> my-event/1: 'up
** Script Error: Invalid path value: 1 ** Near: my-event/1: 'up
>>
The only thing we can do with events is to catch them and replay them. See my example script here: http://www.rebol.cz/~cyphre/event-recorder.r This is really great feature! What do you think? But there is one drawback. Since the events are "invisible" we cannot store them or stream over TCP etc. What a pity. Could you imagine the possibilities? GUI apps with remote control! I hope RT enhance event! datatype for wider usage from the rebol developer side. If you know/find something more about event! datatype dont hesitate to share it on the list! best regards, Cyphre

 [8/11] from: gscottjones:mchsi at: 29-Aug-2002 10:35


Hi, Carl, From: "Carl Read"
> On 29-Aug-02, G. Scott Jones wrote: > > If you have not found your answer, can you give
<<quoted lines omitted: 12>>
> event-function face event action > It's not a show-stopper though...
That is some neat stuff that Cyphre uncovered. I wasn't able to take it any further than he did. 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. Side Moan: I really miss binding to events like as is done in other languages, like Tcl. --Scott Jones

 [9/11] 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
<<quoted lines omitted: 38>>
> 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

 [10/11] from: gscottjones:mchsi at: 30-Aug-2002 4:51


From: "Carl Read"
<snip> > However, if you did understand the function fully and it doesn't
<<quoted lines omitted: 5>>
> is there anything else you can do with one other than referencing > their values?
Hi, Carl, I think you may be on to a good idea. I played a little with the concept and discovered that your reduced block faithfully records the data. Out of curiosity and as a double check on what Cyphre mentioned, I tried making it into and event with: my-event: make event! reduce [event/1 event/2 event/3 event/4 event/5 event/6 event/7 event/8] and as predicted, it did *not* work. Now, just need to find the right example in which to experiment. No time today, though, to mess around with fun stuff. Please let me know if you are successful using this approach. --Scott Jones

 [11/11] from: carl:cybercraft at: 31-Aug-2002 0:26


On 30-Aug-02, G. Scott Jones wrote:
> From: "Carl Read" > <snip>
<<quoted lines omitted: 17>>
> to experiment. No time today, though, to mess around with fun stuff. > Please let me know if you are successful using this approach.
As I said, I'd tried it with one function and it worked, but I have no idea if there'd be cases with that function where it'd trip up, or how many other functions it could be used with. I suspect it'll be okay with some but not with others. -- Carl Read

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted