Ho to get deepest component at mouse position? [message #1759529] |
Wed, 12 April 2017 14:56 |
Frank Gruendel Messages: 22 Registered: January 2014 |
Junior Member |
|
|
Back at the time when I was working on Swing-based user interfaces, I made a tool that prints out the deepest component at the mouse cursor position, along with its parent hierarchy, to the console. I also put a red border around this component to visualize its exact bounds.
Over time, this has helped myself and many of my colleagues tremendously with debugging UI-related problems, so I am contemplating creating a similar tool for RAP applications.
If I understand what I read today correctly, mouse move events aren't available in RAP since they would cause too much traffic. So my idea was to add a key listener to some component way up in the parent hierarchy, like e. g. Display. This worked immediately doing this:
final Display display = Display.getCurrent();
if (null != display)
{
display.setData(RWT.ACTIVE_KEYS, new String[] { "CTRL+F" });
display.addFilter(SWT.KeyDown, new Listener()
{
@Override
public void handleEvent(Event event)
{
System.err.println("HandleEvent");
}
});
The listener is called on every press of <ctrl> + F.
Now I need to determine the current mouse position and then determine the deepest component located at this mouse position.
Thanks for any attempts to steer me in the right direction. The solution will of course be posted here if I find one.
Frank
[Updated on: Wed, 12 April 2017 07:32] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04074 seconds