Mouse Events without timer on C# or GH_Python Component

Hi, I was wondering if there is any way of accessing mouse events in the C# or GH_Python components, without using a timer or without ExpireSolution(), I been experiencing conflicts between multiple components that use ExpireSolution(). Thanks!!!

You’ll simply need to subscribe to an existing event.

blabla.MouseClicked -= OnClick // Unsubscribe to ensure multiple subscriptions
blabla.MouseClicked += OnClick

void OnClick(object sender, MouseEventArgs e)
(Do Something)

The problem is rather not to do this from a script component -> Changing the script will create a new ScriptInstance, which means you’ll have multiple “OnClick” methods -> (ScriptInstance1.OnClick(…), ScriptInstance2.OnClick(…) . So you are loosing any reference to “OnClick”, which makes it impossible to unsubscribe during Runtime. C# sadly doesn’t know any true global variables to workaround this issue.

As a conclusion, you better do any event handling on plugin level only.