Hi,
We are developing a plugin that involves some context-switching. Sometimes we want to be able to cancel out a command that someone might be in the middle of issuing to Rhino if they decide to switch contexts before they are done. This is to prevent some errors in switching contexts.
We do this by issuing keystrokes to the Rhino console: “_EnterEnd”.
We recently discovered, when upgrading our plugin to Rhino 7, that there is an order of operations behavior that is unexpected. When we call RhinoApp.SendKeystrokes("_EnterEnd ", false);, then send another command, the second command issues first, followed by the keystrokes. These keystrokes cancel out the second command rather than whatever the user might have been entering before switching contexts.
I’ve put together a little c# script in grasshopper to illustrate what I mean. We are working with a RHP plugin but the GH script is concise and illustrates things in the console.
We’ve had some luck adding RhinoApp.Wait() after sending keystrokes, but this smells really bad from a best-practices standpoint. I’m worried it could introduce unexpected hangs to our plugin, for example. It also feels like something that is a workaround rather than solving the issue at the source.
Please see the attached script. Also, I found that this occurs in both Rhino 6 and 7, though we only recently discovered this apparent bug in our move to 7, for whatever reason, probably to do with something else within our plugin.
Regardless, this simple script seems to illustrate unexpected behavior, or perhaps I don’t grasp the correct way to work with “SendKeystrokes”.
Either way, your help is very much appreciated!
SendKeystrokes_BugReport_ToMcNeel.gh (4.4 KB)