A couple more thoughts about Announcements

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

A couple more thoughts about Announcements

Igor Stasenko
As far as i can see there is no 'capture' scenario, i.e. tell
announcer to not broadcast the announcement to all subscribers, but
only exclusively to a single one, who requested the capture.
In AXAnnouncements there is an 'interception' , using which you can
achieve the similar result, except that interceptor is added to
each subscription, meaning that you will receive intercepted
announcement + additional data as many times as the number of
subscriptions registered.

Such scenario, as capturing events used heavily in UI, but not only by
UI of course.

So, suppose we made a Sensor which using announcer to broadcast its events.
And there are cases, when you need to get an exclusive capture of all
(or specific kind of events) for a single subscriber, without letting
them handled using normal flow,
until some condition met, when you are releasing capture.

Two examples:
  - mouse capture
  usually, when you start dragging the stuff, you start capturing
mouse events, and release the capture once mouse button released.
  All widgets, over which you dragging a mouse, should not receive any
mouse events, or receive a different event such as 'draggedOver' etc

  - keyboard focus
  pass all keyboard events directly to widget which currently has focus

 - some code examples, by using brute force establishing a loop which
consuming all sensor events until mouse button released or key
pressed.

All of these cases can be supported by adding few things to announcer:
 - tell announcer to insert a subscriber at the starting of the
subscribers list (instead at the end), so it will be first who receive
the announcement
 - make announcer to stop broadcasting announcement down the list, if
particular subscription returns false as result of #handle:
 - when you unsubscribe, things get back to normal without any extra effort

and voila.. we can implement a mouse capture, keyboard focus,
filtering and event transforming scenarios.

--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project