Capture Sup key in Rhino


I want handle the Sup Key when it is pressed and to show a advertencia to confirm if the user wants delete a particular object.

I tried to use the keyboard listener “example command.cs” developed by menno in this thread

But I handle the sup key after rhino deleted the object.

I’ve tried also handle Rhino KeyboardEvent:

RhinoApp.KeyboardEvent += new RhinoApp.KeyboardHookEvent(RhinoApp_KeyboardEvent);

But this event is undhandled when I change the view.

What can I do?

I’m working in c# with visual studio 2010 and RhinoCommon

First of all - it is easy to undo a delete operation for the user - just perform “Undo”. For me, as a user, a dialog asking me to be sure about the deletion would be irritating, rather than helpful. But you may have good reasons to do this.

So then, instead of monitoring the Sup (do you mean “Del” or “Backspace”?) key, why don’t you monitor RhinoDoc.DeleteRhinoObject?
Then, show the message box asking the user if they indeed want to delete the object. If they do not want to delete the object, put this script to perform the undo operation from code:

bool confirmDelete; //defined as outcome of the dialog
if (!confirmDelete)
    RhinoApp.Sendscript("_-Undo _Enter", false);
1 Like

I like your solution. Thanks

Hi again,

I’m testing the DeleteRhinoObject event, but I dont know how differentiate, for example, when a object is deleted because the user pushed the sup or del key, or when the user move the object (In this case the object is deleted and is created a new object in the new position, so that, the DeleteRhinoObject event is fired)

Combine it with RhinoDoc.ReplaceRhinoObject

If moving, you get:


otherwise, only DeleteRhinoObject

1 Like

Ok, Thanks again