Prevent default event action


(Victormunoz) #1

I have managed to intercept some events, like the “Save” messages, in order to run a custom save function.
But I would need also to prevent the default event action. Is this possible?
Does there exist something like in javascript the “event.StopPropagation” function?


(Dale Fugier) #2

Hi @victormunoz,

Perhaps we need more information on what you are trying to do and why? What kind of custom save function are you needing? Is it possible to do this custom saving using a File Export plug-in?

No

– Dale


(Victormunoz) #3

Hi!
I am developing a plugin for loading and saving 3D models through the Rhino command line. The models will be fetched and stored in an external location.
The idea is that once a model had been loaded through the plugin “load” command, then It must not be possible to save it in any other way than the plugin “save” command.
So I need to disable all the Save, Save As and Export options when dealing with such models. I have seen that I can intercept all these events, and in some cases redirect them to the plugin saving methods, but I have not seen how to stop the built-in action (for example showing the save as dialog).
Is that possible?


(Willem Derks) #4

Hi Victor

Maybe you can import the file in an empty file. Or device a way to open the file as read-only.

-Willem


(Dale Fugier) #5

Hi @victormunoz,

It is not possible to override Rhino’s Save, SaveAs, Export, etc., commands to do something different. Also, there is also no good way canceling any of these commands once they have been initiated by the user.

Even if we did provide a way of doing the above, there is nothing that prevents a 3rd party developer, like yourself, from writing their own custom Save, SaveAs, Export, etc. commands, just like you are doing.

If you are concerned about the user running the incorrect Save command, then you might consider providing a custom toolbar that has a Save button that runs your version. You can also modify Rhino’s command aliases to run your version of our command. And, you can even write a Skin DLL that replaced Rhino’s menu with your own, so if they click File -> Save it runs your save command.

Finally, using an event watcher you can be notified when one of the above commands begin and end. So perhaps you want to display a warning then the Save command begin, for example. Or, when the command ends just delete the file that was saved. (Note this probably won’t work for 3dm files because of Rhino’s file locking.)

Let me know if you have any questions.

– Dale