Hi Ken,

On Wednesday 16 December 2009 Ken MacDonald wrote:
> Anyway, I guess I can just removeListener() when I want the listener not to
> fire, then add it back after I'm through messing with the object. I've
> thought up what may be an interesting way for objects themselves to keep
> track of their own listeners, something like this semi-pseudo-code:
> 
> myobj = new qx.something
> 
> mylistener: function(e) {
> // does something with e
> }
> 
> myobj.listenerId = myobj.addListener("mouseup", mylistener);
> myobj.listenFunc = mylistener;
> 
> then define a generic:
>  removeMyListener(obj) {
>        removeListenerById(obj.listenerId, obj.listenerFunc)
>        obj.listenerId = null;
> }
> 
> and restore it:
>     addMyListener(obj, type) {
>     obj.listenerId = obj.addListener(type, obj.listenerFunc);
> }
> 
> So I think I'll give that a try, (expanding to a dict to allow possible
> multiple listeners per obj).
> 
> However, I also thought it would be neat to have some support for a qooxdoo
> function that would disable a listener or all listeners on an object
>  without removing them, something like:
> 
> myobj.deafenListeners([optional list of types (or IDs?) to deafen, default
> ALL]) and
> myobj.restoreListeners([list again, default ALL]);
> 
> Anyone think this is either possible or even maybe a good idea?
Interesting thoughts. Every listener method is internally managed by 
(surprise!) the event managers. So I guess it would be possible to disable all 
listeners by saving the existing handlers and setting an empty function.

This might be a good thing for own objects/widgets but when you want to use 
this at framework objects/widgets disabling all listeners might be a bad idea, 
since the application developer is not aware of all listeners of e.g. the 
widget. This then might end up in some disfunctional state.

So I guess it would be better to leave this at application level and implement 
there the generic methods to disable specific objects, since the application 
developer knows best which listeners at which object can safely be disabled 
and which not.

Anyway, many thanks for your thoughts and the pseudo-code. Much apprieciated.

cheers,
  Alex

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to