Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 168715

Summary: MouseEvent button on MouseDraggedEvent
Product: [Tools] GEF Reporter: Manuel Selva <manuel.selva>
Component: GEF-Legacy Draw2dAssignee: gef-inbox <gef-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: enhancement    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Snippet which showing the value of me.button is always 0
none
Proposed patch , modification in SWTEventDispatcher dispatchMouseMoved method none

Description Manuel Selva CLA 2006-12-20 11:04:18 EST
Hi all,

I am using draw2d in an Eclipse plugin. Some of my figures uses MouseMotionListener and especially the MouseDragged(MouseEvent me) method.
My problem is that the me Mouse event button field is always equal to 0. I know i can test the stateMask but it would be more easier for programmers to have the button field set with the good value (1 for button 1, 2 for button 2) respecting the SWT specifications. 

Manu
Comment 1 Manuel Selva CLA 2006-12-20 11:16:11 EST
Created attachment 55969 [details]
Snippet which showing the value of me.button is always 0

When clicking on the click here figure a label is displayded indicating the event nature and the associated button.
Comment 2 Manuel Selva CLA 2006-12-20 11:18:38 EST
Created attachment 55970 [details]
Proposed patch , modification in SWTEventDispatcher dispatchMouseMoved method

Proposed solution,

Add a test in SWTEventDispatcher dispatchMouseMoved method on me.stateMask to find the pressed button.
Comment 3 Randy Hudson CLA 2006-12-20 12:29:28 EST
As your patch demonstrates, there is no way to store a meaningful value when more than one of the 5 mouse buttons is pressed. We could add a convenience method, but it is a very small amount of code that is being "saved".
Comment 4 Manuel Selva CLA 2006-12-20 16:38:21 EST
(In reply to comment #3)
> As your patch demonstrates, there is no way to store a meaningful value when
> more than one of the 5 mouse buttons is pressed. We could add a convenience
> method, but it is a very small amount of code that is being "saved".
> 

Thanks for your quick answer Randy,

What do you mean by convenience method ? On which object ? Mouse Event ? And what do you mean by "small amount of code that is being "saved"" ?

Concerning the fact that we can't store a meaningfull value if more than one button is pressed i agree with you. But does it take sense for any GUI to react to a "bi button" mouse event ? 

Manu
Comment 5 Randy Hudson CLA 2006-12-20 17:37:13 EST
You are complaining about having to call:
    (event.getState() & SWT.BUTTON1) != 0;
that is not much bigger than:
    event.getButton() == 1;
Comment 6 Randy Hudson CLA 2006-12-20 17:38:31 EST
> You are complaining about having to call:

Sorry, "complaining" was not the right word choice. Community feedback is always welcome.
Comment 7 Manuel Selva CLA 2006-12-21 02:20:34 EST
You are right, 

I can directly use (event.getState() & SWT.BUTTON1) != 0; .
As you told it i am not complaining but just trying to help you and to 'contribute' Draw2D giving you my feedback...

Thanks

Manu
Comment 8 Randy Hudson CLA 2006-12-21 08:52:40 EST
re-closing
Comment 9 Randy Hudson CLA 2006-12-21 08:53:27 EST
worksforme