Menu Position

I have made a custom parameter, which displays a custom menu on Left Mouse Down, But I am having issues with the location of the menu, whatever I set it too it seems to ignore and default to the top left corner of the screen, Im sure that it is something really obvious that I am missing, but im still new to the grasshopper SDK, so any pointers would be great!

'create menu
If e.Button = MouseButtons.Left Then
Dim menu1 As New ToolStripDropDown

                Owner.buildMenu(menu1)

                'show
                Dim bX As Double = Bounds.X
                Dim bY As Double = Bounds.Y + 60
                Dim bW As Double = Bounds.Width

                menu1.Location = New Drawing.Point(bX, bY)
                menu1.Width = bW
                menu1.Show()
            End If

(couldn;t seem to upload the vb file so I have change the extension to txt)
bin_CustomParam.txt (9.1 KB)

The attribute Bounds are specified in Canvas coordinates. The menu location will have to specified either in screen or control coordinates. I’d also pass in the point to the Show() method rather than setting the location ahead of time.

So step one is to transpose your canvas coordinates to control coordinates, then call Show() with both the canvas control as the hosting entity and the transposed coordinate as location.

You can access the transforming methods for canvas to control coordinates and back via the Canvas.Viewport object.

1 Like

Thanks David Worked a Charm!
T