Nevron Forum

Right Button pressed in a Shape

https://www.nevron.com/Forum/Topic7409.aspx

By Luis Miguel Perez Lopez - Tuesday, January 29, 2013

I have created an array of Nshapes, and I need to know when a Shape is selected with the right or the left mouse button. I have added this:

AddHandler DrawingView.EventSinkService.NodeSelected, AddressOf EventSinkServiceNodeSelected

This works but ONLY with the LEFT button. When I press the right button in a shape, that event is not fired.

I tried with this another:

AddHandler DrawingView.EventSinkService.NodeMouseDown, AddressOf EventSinkServiceNodeMouseDown

But it doesn't work AT ALL. I was seeing this page :

http://helpdotnetvision.nevron.com/UsersGuide_ConceptualOverview_Diagram_Services.html

But I don't find the solution. Does anybody can help me ?
By Nevron Support - Tuesday, January 29, 2013

Hi Luis,

Please elaborate what you are trying to achieve? Do you want shape to be selected by clicking on a shape with either the left or the right mouse button, or do you simply want to be notified when a shape is clicked with the left or the right mouse button?

By Luis Miguel Perez Lopez - Tuesday, January 29, 2013

What I want is when the user press the right button on a shape, a context menu has to be opened.
By Charley Lee - Wednesday, January 30, 2013

I was able to get it working using this event handler:

NDrawingDocument.EventSinkService.NodeMouseUp

It has a Button property on the args that tells you which button was pressed on the mouse.

Hope that helps,

Charley
By Luis Miguel Perez Lopez - Thursday, January 31, 2013

I tried this event handler but I get the same as the other event handler (NodeMouseDown)
By Charley Lee - Thursday, January 31, 2013

Weird, it works for me, although I'm using C#.  I'm using 13.1.7.12 version of Nevron.Diagrams.  What version are you using?
By Luis Miguel Perez Lopez - Monday, February 4, 2013

I'm using 9.5.11.12 and visual basic 2005 Team Edition
By Luis Miguel Perez Lopez - Tuesday, February 5, 2013

I've got it . First I had to add a handler for the drawingview:

AddHandler DrawingView.MouseDown, AddressOf DrawingView_MouseDown

And this is the code for de sub

Private Sub DrawingView_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DrawingView.MouseDown

Dim ActiveShape As Object = DrawingView.LastActiveDocumentContentHit(DrawingView.GetMousePositionInDevice(), -1, Nevron.Diagram.Filters.NFilters.TypeNShape)

Dim XShape As NShape = CType(ActiveShape, NShape)

If e.Button = Windows.Forms.MouseButtons.Right And Not XShape Is Nothing Then

ContextMenuStripTree.Show(DrawingView, CInt(e.X), CInt(e.Y))

End If

End Sub