sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Checkbox Menu item

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 430 Views 2 Watching
    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.
    • thomthomT Offline
      thomthom
      last edited by

      Is it possible to create an menu item which you can toggle on/off. A checkbox menu item? Like the Hidden Geometry menu item under the View menu?

      Thomas Thomassen β€” SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Sure can, Thomas. This contrived example works. Just change the global $f to true in the Ruby Console to see the checkmark in the menu.

        
        $f = false
        
        def hi
          puts "hi"
        end
        
        menu = UI.menu("Plugins")
        item = menu.add_item("Hi") { hi() }
        
        def vp
          return MF_CHECKED if $f == true
          return MF_UNCHECKED if $f == false
        end
        
        menu.set_validation_proc(item) { vp }
        
        
        

        Hi

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Great! Thanks! πŸ‘

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            btw, where did you find them constants?

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              in UI::Command, where else? πŸ˜†

              @unknownuser said:

              Your procedure should return either MF_ENABLED, MF_DISABLED, MF_CHECKED, MF_UNCHECKED, or MF_GRAYED.

              Hi

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                I see. I never looked that that class yet. I just saw the UI::Menu class and thought that was the one. And there was nothing on the constants there.

                It says that UI.Command is the preferred way to add toolbars and menu items, but why? what's the difference and benefit?

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

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

                Advertisement