Mouse click without timer?

Hi @anon39580149

This is a possible way to make this work:

import Rhino

import scriptcontext as sc

key = 'MyViewEventInfo'

class MyViewEventInfo:
    def __init__(self, component):
        self.component = component
        Rhino.Display.RhinoView.SetActive += self.OnSetActiveViewHandler
        
    def Release(self):
        Rhino.Display.RhinoView.SetActive -= self.OnSetActiveViewHandler
        
    def OnSetActiveViewHandler(self, sender, e):
        self.component.ExpireSolution(True)

if sc.sticky.has_key(key):
    if not on:
        handler = sc.sticky[key]
        if handler: handler.Release()
        del sc.sticky[key]
else:
    handler = MyViewEventInfo(ghenv.Component)
    sc.sticky[key] = handler

view = sc.doc.Views.ActiveView
a = (view.ActiveViewport.Name)

Please note that nothing happens “immediately”. It’s a matter of making it happen “subsequently” (in a queue) and requesting a new solution after that.

view-event-handler.gh (5.2 KB)

2 Likes