Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » mouseDown/widgetSelected/mouseUp behavior
mouseDown/widgetSelected/mouseUp behavior [message #654738] Wed, 16 February 2011 21:12 Go to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
Hi,
I have both SelectionAdapter and MouseAdapter tied to one widget (List).

Under Linux gtk.x64 sequence is mouseDown -> widgetSelected -> mouseUp
while under win32.x86 i see mouseDown -> mouseUp -> widgetSelected

Can someone please confirm this is indeed the case and I'm not seeing
some artifact of my environment?

Side question: is there some easy way to determine on which element of
the list the mouse button happened?
I mean: inside the mouseDown or mouseUp handler I have access to a
MouseEvent containing widget-relative mouse coordinates; how can I
translate that to the Index of the item under cursor? I need something
akin to Tree.getItem(Point).

TiA
Mauro
Re: mouseDown/widgetSelected/mouseUp behavior [message #655457 is a reply to message #654738] Mon, 21 February 2011 09:28 Go to previous messageGo to next message
Praveen  is currently offline Praveen Friend
Messages: 86
Registered: July 2009
Member
There is a case that sequence of Mouse events might be inconsistent (eg https://bugs.eclipse.org/bugs/show_bug.cgi?id=79925). In your case, if you find the sequence of events as inconsistent across platforms, then please raise a bug explaining the impact on your scenario.

The below excerpt of the snippets helps you to print the selected elements of the list :

list.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event e) {
String string = "";
int [] selection = list.getSelectionIndices ();
for (int i=0; i<selection.length; i++) string += selection [i] + " ";
System.out.println ("Selection={" + string + "}");
}
});
Re: mouseDown/widgetSelected/mouseUp behavior [message #655477 is a reply to message #655457] Mon, 21 February 2011 10:10 Go to previous message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
Il 21/02/2011 10:28, Praveen ha scritto:
> There is a case that sequence of Mouse events might be inconsistent (eg
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=79925). In your case, if
> you find the sequence of events as inconsistent across platforms, then
> please raise a bug explaining the impact on your scenario.

Scenario is simple: I want to do something after a certain List element
is selected via mouse, but not if it is selected otherwise.
I tied action to mouse-up and this works under windows, but not under
linux/gtk because the element is not (yet) selected.

I installed a workaround that keeps track of what happened.

Does it make sense to raise a bug?
The one You cite is sitting there since 2004 and none even took the pain
to comment on it :(

>
> The below excerpt of the snippets helps you to print the selected
> elements of the list :
>
> list.addListener (SWT.Selection, new Listener () {
> public void handleEvent (Event e) {
> String string = "";
> int [] selection = list.getSelectionIndices ();
> for (int i=0; i<selection.length; i++) string += selection [i] + " ";
> System.out.println ("Selection={" + string + "}");
> }
> });
Thanks.
I already instrumented my code in a similar way and I can confirm the
behavior is indeed different.

Regards
Mauro
Previous Topic:Combo look-and-feel on Windows 7
Next Topic:Showing log file in TextViewer
Goto Forum:
  


Current Time: Thu Apr 25 09:47:33 GMT 2024

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

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

Back to the top