GhPython rs.Messagebox messing up grasshopper selection

I’m trying to create a pop-up message box using ghpython and getting some strange behaviour. Every second time I press the toggle to activate the window and pressed ok in the messagebox the grasshopper interface becomes partially unresponsive: I cannot select components and I cannot window select anything. Hovering over inputs still shows the information on input and output. It stays like this until I press the boolean button again.
Here’s a video showing the behaviour on my computer:

200716 Python (3.0 KB)
Running Version 6 SR27

Pressing the button sends 2 messages to the GhPython control. It sends ‘True’ when you click and then sends ‘False’ when you release. Because your code blocks right after it receives ‘True’ by opening a MessageBox things get messed up for some reason. Using a ‘Toggle Button’ only sends one message every time it’s pressed so maybe it’s a better option. You could also keep using the original ‘Button’ control and ignore the first message. Something like this:

if 'previousbool' in globals() and previousbool == True:
    rs.MessageBox("Message", 0, "WARNING")
globals()['previousbool'] = bool 

@DavidRutten or @andheum may have a better suggestion.