Right Click Menu Items
-
I’ve noticed with some plugins that when you create something within them you can then right click on the object and plugin specific items are shown in that menu.
I would like to do something like that for the truss and foundation plugin where a user can right click and then be shown the option to edit the roof or foundation assembly.
Can someone point me in the right direction for adding this type of functionality.
-
Here's a simple example from part of my
SectionCutFacetool's code.
That tool actually ONLY works from the right-click context-menu, when there's a suitable selection...### Setup Context-menu unless file_loaded?(__FILE__) UI.add_context_menu_handler{|menu| if TIG;;SectionCutFace.ok() menu.add_item( "#{MENUTXT}" ){ TIG;;SectionCutFace.new() } end ###...etc...### } file_loaded(__FILE__) end #unlessTo explain the parts a little...
TheTIG::SectionCutFace.ok()method returnstrueif the current selection contains just one Section-Plane.
TheMENUTXTis a Constant which I had set up earlier - so it can involve translations etc - you could just use a text-string.
If that context-menu item is chosen, then theTIG::SectionCutFace.new()method runs [using the selected Section-Plane]...
You can simply replace bits with your own methods etc.
You can add several possible methods, each with their own 'tests', which can have multiple hits etc if needed...
You can also add a menu item based on your tool-name, and add commands into that as they become appropriate - just like you do in the top menu bar with a sub-item set up... -
Thank-you for the example and explanations.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement