Hi Trevorׅ
Thanks for the reply, well i do agree with your recommendation on how to decide whether to use ScriptUI or CEP, that is the reason i am more inclined towards using ScriptUI with very simple UI solution. The problem arises when something as simple as event handlers show a behaviour that is not reliable at all.
Trevorׅ wrote On the one hand the custom event listeners are / were more powerful allowing to do things you can't do with onClick |
Could you please elaborate on this?
-Manan
Hi Manan,
Sorry for my slow response. I have had and still have a bad case of flue.
I highly recommend reading both Peter Kahrel's excellent ScriptUI For Dummies and the "JavaScript Tools Guide CC.pdf " that one can get to via the ESTK (IMHO the only useful function of the ESTK)
The JavaScript Tools Guide CC.pdf has a good section on UI including which eventListeners can be added to which elements and also which onEvents work for which elements.
Some example cases for using addEventListener() and not onEvents could be.
1) OnEvents don't provide the data of the event so if you want to monitor keyboard or mouse events addEventListener would be the way to go. (Which key was pressed with which modifier / Which mouse button was clicked / where on the screen)
2) Some elements like an image you can use addEventListener('click') / mouseup / mousedown but not onClick (AFAIK never tried image.onClick() but I don't think that it works)
3) addEventListener Events can be filtered by target or whatever filter one desires and then one can use eventObj.preventDefault ( ) and eventObj.stopPropagation ( )
4) One can listen and dispatch custom events.
HTH
Trevor