Tony Garnock-Jones-3 wrote
On 2016-05-20 9:19 AM, marcel.taeumel wrote:
Then you can do things like "if you type a y, make a z out of it and vice versa": [...]
Would it be possible to have "if you type y, pretend you typed abcde"?
That is, instead of having the filter yield zero or one events (for refiltering??), could it yield zero or more events?
Tony
Hi Tony,
yes, I think so. You event create code is kind of awkward but I would work like this:
... [:event :target | ... event hand handleEvent: ((KeyboardEvent newFrom: event) stroke: $a); handleEvent: ((KeyboardEvent newFrom: event) stroke: $b); handleEvent: ((KeyboardEvent newFrom: event) stroke: $c); handleEvent: ((KeyboardEvent newFrom: event) stroke: $d); handleEvent: ((KeyboardEvent newFrom: event) stroke: $e). event wasIgnored: true. event].
Note that this API "(KeyboardEvent newFrom: event) stroke: $a" does not exist at the moment. It is not that convenient to generate new events but "event hand handleEvent: ..." should work. I have not tried this yet, however, the event dispatching and handling code should be reentrant.
I think that I should separate upstream and downstream event filters. When calling "ActiveHand addEventFilter: ..." it is only downstream because this is where event processing starts. When calling "someMorphInTheWorld addEventFilter: ..." this is rather upstream because it starts at Morph >> #handleEvent:. Hmm... downstream event filters for any morph would be possible in Morph >> #processEvent:using:.
Still ... I am struggling with the concept of keyboard focus and mouse focus. There, you directly call Morph >> #handleFocusEvent:, which calls Morph >> #handleEvent:. No bubbling up, no bubbling down. If focused morphs want to bubble down, they have to call Morph >> #processEvent: and watch for the #rejected pattern. See UserDialogBoxMorph >> #handleFocusEvent: for an example. I now that this is a performance thing. If you type in a text field, you do not want to bubble all the way down from the world. Again and again. And again.
Best, Marcel
-- View this message in context: http://forum.world.st/Event-filters-for-user-input-events-i-e-mouse-clicks-e... Sent from the Squeak - Dev mailing list archive at Nabble.com.