Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Ho to get deepest component at mouse position?
Ho to get deepest component at mouse position? [message #1759529] Wed, 12 April 2017 10:56 Go to next message
Eclipse UserFriend
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 03:32] by Moderator

Re: Ho to get deepest component at mouse position? [message #1759542 is a reply to message #1759529] Wed, 12 April 2017 05:10 Go to previous messageGo to next message
Eclipse UserFriend
Frank,

Your approach sounds like it would work. I've typically just explicitly changed the widget background colors in code to help with debugging. There is the SWT spy plugin [1], but I can't remember if it will run under RAP. If not, maybe it could with a little rework.

[1] https://www.eclipse.org/swt/tools.php

Hope that helps,
Cole Markham
Re: Ho to get deepest component at mouse position? [message #1760725 is a reply to message #1759529] Tue, 02 May 2017 08:36 Go to previous messageGo to next message
Eclipse UserFriend
Some sample code that provides a debugging tool to highlight the control under the mouse cursor and print its parent hierarchy to the console can be found at https://www.eclipse.org/forums/index.php/m/1760724/#msg_1760724 as of a minute ago Smile
Re: Ho to get deepest component at mouse position? [message #1760726 is a reply to message #1759542] Tue, 02 May 2017 08:37 Go to previous message
Eclipse UserFriend
Thanks for pointing out the spy plugin. I wasn't aware of it before, and I will have a look at it soon.
Previous Topic:Where to post demo code?
Next Topic:Highlight deepest component under mouse cursor and print parent hierarchy to console
Goto Forum:
  


Current Time: Fri Jul 25 11:17:51 EDT 2025

Powered by FUDForum. Page generated in 0.05167 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top