Get Mouse Button State in IronPython

How do I read the mouse button state from within an IronPython script component? I’m looking for something like System.Windows.Input.Mouse.LeftButton == System.Windows.Input.MouseButtonState.Pressed, but the System module in IronPython doesn’t have the Mouse methods.

You might need to reference the relevant assembly before importing it. Not all .NET assembles are referenced out of the box. That said, you probably want to go through RhinoCommon instead:

https://developer.rhino3d.com/api/rhinocommon/rhino.ui.mousecallback

I don’t need to make an event handler. I just need the instantaneous state of the mouse button at a particular point the the script.

Ah, in that case try referencing these assemblies. Not sure if it works in the new script editor, but I think it’s using the same IronPython:

That works. Thanks!

1 Like