Why is scroll processed via handler while resize is processed via overriden method in ScrollPanel?

主宰稳场 提交于 2019-12-25 02:24:45

问题


Why is GWT designed in such a way? What is the principal difference between resize and scroll events?


回答1:


Because there's no event for resizing in browsers (there's resizing at the window-level, but not element-level), contrary to scroll events.

Thus, resizing "notification" is "emulated" in GWT: if you use a RootLayoutPanel or ResizeLayoutPanel, it'll listen for window resize events and propagates them downwards to its RequiresResizechildren (which will propagate downwards too, if they are ProvidesResize widgets themselves).
Explicitly setting the size of a ProvidesResize widget will also notify its RequiresResize children; as well as resizing areas of a layout panel (programmatically for DockLayoutPanel and LayoutPanel –among others–, and/or done by the user for a SplitLayoutPanel or StackLayoutPanel).

You'll note that ScrollPanel is both a RequiresResize (will be notified by its parent ProvidesResize widget that its size might have changed) and ProvidesResize (will notify its child widget if its a RequiresResize).



来源:https://stackoverflow.com/questions/8389599/why-is-scroll-processed-via-handler-while-resize-is-processed-via-overriden-meth

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