For what is the AttachEvent

家住魔仙堡 提交于 2020-01-03 15:59:21

问题


i really doesnt understand for what the class AttachEvent or the addAttachHandler is. For what is this usefull? could somebody post an example for that? Thx a lot.


回答1:


The AttachEvent informs you when a Widget is either attached or detached from the actual page. If something isn't attached, there is no way its elements can be visible or interacted with, so it can be beneficial to know when it isn't available for interaction.

The main thing that GWT itself uses this knowledge for is for wiring up event handling code. If a widget isn't attached to the dom, it can't be interacted with, so all handlers are temporarily detached from the dom. This is done as part of GWT's method for dealing with memory leaks (see http://code.google.com/p/google-web-toolkit/wiki/DomEventsAndMemoryLeaks and http://code.google.com/p/google-web-toolkit/wiki/UnderstandingMemoryLeaks for more details). You generally shouldn't need to worry about this detail, unless you are wiring in your own dom listeners, or building container for other widgets. One of the primary duties of a container is to inform its children when it has been attached or detached.



来源:https://stackoverflow.com/questions/10131920/for-what-is-the-attachevent

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!