[squeak-dev] Re: Event filters for user input events (i.e. mouse clicks etc.)

marcel.taeumel Marcel.Taeumel at hpi.de
Thu May 19 12:33:59 UTC 2016


Tony Garnock-Jones-3 wrote
> On 05/18/2016 12:12 PM, tim Rowledge wrote:
>> Seems to me that a significant part of the potential
>> usefulness would be to have filters transform events [...]
> 
> One interesting approach would be to take a leaf from functional
> programming.
> 
> Instead of returning a boolean from a filter, you'd have it expect a
> continuation block.
> 
>   filter := PluggableEventFilter new on: [:e :target :k |
>      Transcript showln: e printString.
>      k value: e ].
> 
> It would invoke the block with some event, or not, according to the
> filtering decision.
> 
> This gives it an opportunity to pass on either its argument; or a copy
> of its argument; or its argument, modified; or something unrelated.
> 
> Tony


Hi Tony,

I like the idea of filters transforming events. Here, the filter could just
return the transformed event instead of a boolean value. (Note that the last
statement in a block determines its return value.)

Here is a new version of event filter that does that:  event-filters.cs
<http://forum.world.st/file/n4896027/event-filters.cs>  

Don't forget to revert the previous change set because I cleaned up this
one. Use a fresh trunk image at best.


wnd := ActiveWorld submorphs third. "some window?"
filter := PluggableEventFilter on: [:evt :target |
	evt isMouseOver ifFalse: [
	Transcript showln: evt printString, ' ', target printString].
	evt wasIgnored: true.
	evt].
wnd addMouseFilter: filter.
wnd removeMouseFilter: filter.


Best,
Marcel



--
View this message in context: http://forum.world.st/Event-filters-for-user-input-events-i-e-mouse-clicks-etc-tp4895521p4896027.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.


More information about the Squeak-dev mailing list