Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting left/right mouse click from IMAQVIEWER1 event

I am able to find Left and Right constants under CWIMAQVIEWER1.MouseButton but no idea what to compare these to in order to ascertain which button clicked.  Or whether to do this using

_DCWIMAQViewerEvents_MouseUpEvent or _DCWIMAQViewerEvents_ImageUpEvent.

 

Furthermore, there seem to be certain contexts wherein left click brings up the palette controls.  Right click continues to work as intended.  No idea why.  SInce my event handling code makes no mention of what mouse button is clicked, I cannot see not I could inadvertently have mapped left click to default right click action.

 

If unable to untangle the issue with regard to left click bringing up right-click palette control context menu, I may have to explitly handle left/right click in order to keep this misbehavior under control.

 

Thanks for any help which can be offered.  Other posts about differentiating left/right mouse on this forum do not seem to relate to VB.NET ... or else have variables (such as "Button") which are never declared within sample code provided.  I am sure this is not a difficult thing to do.  Simply not directly documented within a VB.NET context.

 

Like I said ... thanks.

0 Kudos
Message 1 of 2
(3,184 Views)

Answered my own question.  Cannot handle this in handler subroutines for CWIMAQVIEWER1.Click or CWIMAQVIEWER1.DblClick,  However, mouse button clicked can be identified using:

 

     e.button = LEFT_MOUSE_CLICK

or

    elbutton = RIGHT_MOUSE_CLICK

 

where LEFT_MOUSE_CLICK = 1 and RIGHT_MOUSE_CLICK = 2

 

within handlers for mouse and image up/down events handlers. I found the following handlers / events to posess a "button" attribute:

 

CWIMAQVIEWER1.MouseDown                    _DCWIMAQViewerEvents_MouseDownEvent

CWIMAQVIEWER1.ImageDown                          _DCWIMAQViewerEvents_ImageDownEvent

CWIMAQVIEWER1.MouseUp                             _DCWIMAQViewerEvents_MouseUpEvent

CWIMAQVIEWER1.ImageUp                              _DCWIMAQViewerEvents_ImageUpEvent

  

Where right-click is supposed only to bring up viewing tools/palette controls, I simply added the statemetn:

 

    If e.button = RIGHT then exit sub

 

to the handlers associated wit the events listed above.  Of course, specialized left/mouse button behaviors could be implemented within the same handler subroutines.  Not so object-oriented but it works.  Anyway, if I were going to do real OOP development I would prefe to use a langauge designed from the beginning for OOP, such as: Java, C++ or C#.

0 Kudos
Message 2 of 2
(3,167 Views)