Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » MenuDetectListener: how can I know if from keyboard or mouse
MenuDetectListener: how can I know if from keyboard or mouse [message #661437] Thu, 24 March 2011 16:36 Go to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
Whe processing the menuDetected event in a MenuDetectListener, how can I tell if triggered from a keyboard or mouse event.

Why do I want to know?
Because I would like to know if mouse coordinates can be used or not.
It is for the context menu of a table, which is dependent on the right-clicked cell.

Example:

            MenuDetectListener detectListener  = new MenuDetectListener() {
                @Override
                public void menuDetected(M enuDetectEvent e) {
                    Point pt = tbl.to Control(e.x, e.y);
// Is pt the point where the user has right clicked or pressed by keyboard and should I ignore the place.
                }
            };


Thanks for any help.

David
Re: MenuDetectListener: how can I know if from keyboard or mouse [message #662154 is a reply to message #661437] Tue, 29 March 2011 14:33 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi David,

The MenuDetect event does not contain this info. I was going to suggest
that you could listen for SWT.MouseDown/Up on the Table, and that a
MenuDetect that comes in between these would indicate that it was triggered
by the mouse, but I see that this approach would not currently work on OS X
due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=79930 . I can't think
of another approach to suggest, other than to consider changing the
convention slightly, such that if the pointer is detected to be within the
Table then the context menu for the cell it's over is always shown
regardless of how it was triggered. This may or may not make sense,
depending on your app.

Grant


"David P
Re: MenuDetectListener: how can I know if from keyboard or mouse [message #662314 is a reply to message #662154] Wed, 30 March 2011 08:48 Go to previous message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
For instance, I use it for copying the content of the current cell to the clipboard. I'm not very worried for this issue, but it is a little confusing to the user to deal with a cell, that could not be in the selected row.

Grant Gayed wrote on Tue, 29 March 2011 10:33
Hi The MenuDetect event does not contain this info. I was going to suggest
that you could listen for SWT.MouseDown/Up on the Table, and that a
MenuDetect that comes in between these would indicate that it was triggered
by the mouse, but I see that this approach would not currently work on OS X
due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=79930 . I can't think
of another approach to suggest, other than to consider changing the
convention slightly, such that if the pointer is detected to be within the
Table then the context menu for the cell it's over is always shown
regardless of how it was triggered. This may or may not make sense,
depending on your app.

Grant

Previous Topic:Autocompleting combo boxes
Next Topic:Re: Exception when unlocking windows' screensaver
Goto Forum:
  


Current Time: Sun May 31 14:51:01 GMT 2020

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

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

Back to the top