Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:56 Go to next message
Frank Gruendel is currently offline Frank GruendelFriend
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

Re: Ho to get deepest component at mouse position? [message #1759542 is a reply to message #1759529] Wed, 12 April 2017 09:10 Go to previous messageGo to next message
Cole Markham is currently offline Cole MarkhamFriend
Messages: 143
Registered: July 2009
Location: College Station, TX
Senior Member

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 12:36 Go to previous messageGo to next message
Frank Gruendel is currently offline Frank GruendelFriend
Messages: 22
Registered: January 2014
Junior Member
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 12:37 Go to previous message
Frank Gruendel is currently offline Frank GruendelFriend
Messages: 22
Registered: January 2014
Junior Member
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: Sun May 20 13:43:51 GMT 2018

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

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

Back to the top