I am trying to have a contextual menu (right click) to work on a canvas which should be able to move inside another canvas. I have this code in MouseDown
Blockquote
If IsContextualClick and Mire.Visible Then
ElseIf not IsContextualClick Then
myX=X
myY=Y
End if
Blockquote
var t(-1) as String
var w As integer=15.75/reso
var h As Integer=19/reso
var a As Integer=4/reso
Select Case selectedItem.Text
Case “50x50”
Mire.Width=50/reso
Mire.Height=50/reso
Case “100x100”
Mire.Width=100/reso
Mire.Height=100/reso
case “160x120”
Mire.Width=160/reso
Mire.Height=120/reso
case “200x200”
Mire.Width=200/reso
Mire.Height=200/reso
case “300x220”
Mire.Width=300/reso
Mire.Height=220/reso
case “Team”
case “Other…”
MireSizeWin.ShowModal
case “4P”
Mire.Width=72/reso
Mire.Height=66/reso
case “Hide Mire”
me.Visible=False
End Select
Return True
Blockquote
I can move the canvas with a left click and drag but nothing happened with a the right click
This event is called when it is appropriate to display a contextual menu for the control.
This event handler is the recommended way to handle contextual menus because this event figures out whether the user has requested the contextual menu, regardless of how they did it. Depending on platform, it might be in the MouseUp or MouseDown event and it might be a right+click or by pressing the contextual menu key on the keyboard, for example.
var t(-1) as String
var w As integer=15.75/reso
var h As Integer=19/reso
var a As Integer=4/reso
Select Case selectedItem.Text
Case "50x50"
Mire.Width=50/reso
Mire.Height=50/reso
Case "100x100"
Mire.Width=100/reso
Mire.Height=100/reso
case "160x120"
Mire.Width=160/reso
Mire.Height=120/reso
case "200x200"
Mire.Width=200/reso
Mire.Height=200/reso
case "300x220"
Mire.Width=300/reso
Mire.Height=220/reso
case "Team"
case "Other..."
MireSizeWin.ShowModal
case "4P"
Mire.Width=72/reso
Mire.Height=66/reso
case "Hide Mire"
me.Visible=False
End Select
Return True
The problem is the code in MouseDown
If IsContextualClick and Mire.Visible Then
ElseIf not IsContextualClick Then
myX=X
myY=Y
End if
Return True
If I use this code, I can move the canvas around but when I right clicked nothing is happening
If I don’t put any code I can use the right click and the contextual menu occurred …
You need to respond to MouseDown with false to indicate to the framework that you did not handle the mouse event for the contextual click. Returning true tells the framework that you handled the mouse event and that it should not. This is detailed in the documentation for the MouseDown event.
The easiest way would be to return early, adding a bunch of ifs with nesting can get really cumbersome. At the top of MouseDown add this:
Right, but there’s something to be said about giving people an arguably wrong answer immediately after someone posts the correct events with links to the documentation.
Mark it as the solution, by clicking ‘solution’ at the bottom of the post you used ,please. Otherwise the post shows up as ‘in progress/ unsolved’ forever.