• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Right Click Menu Items

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 1.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    medeek
    last edited by 11 Nov 2017, 16:37

    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.

    Nathaniel P. Wilkerson PE
    Medeek Engineering Inc
    design.medeek.com

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 11 Nov 2017, 17:12

      Here's a simple example from part of my SectionCutFace tool'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 #unless
      

      To explain the parts a little...
      The TIG::SectionCutFace.ok() method returns true if the current selection contains just one Section-Plane.
      The MENUTXT is 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 the TIG::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...

      TIG

      1 Reply Last reply Reply Quote 0
      • M Offline
        medeek
        last edited by 11 Nov 2017, 18:27

        Thank-you for the example and explanations.

        Nathaniel P. Wilkerson PE
        Medeek Engineering Inc
        design.medeek.com

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          1/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement