问题
I'm trying to find where a given menu item (which is within a drop down vertical menu) is located on the screen but getAbsoluteTop() getAbsoluteLeft() are zero even when the menu item is showing on the screen
The actual Element by the way seems to be
Any idea how I can find where a menu item (within a floating drop down menu) is on the screen please?
Thanks!
回答1:
Most likely, you ask for the coordinates before the menu item is fully rendered. Try using a Scheduler (GWT: Timer and Scheduler Classes) to wait until the menu item is fully rendered and then ask for the coordinates inside the execute
method.
来源:https://stackoverflow.com/questions/27644719/gwt-menuitem-in-a-submenu-has-zero-getabsolutetop-getabsoluteleft