• Login
sketchucation logo sketchucation
  • Login
🔌 Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

One-shot toolbar buttons?

Scheduled Pinned Locked Moved Developers' Forum
11 Posts 3 Posters 357 Views 3 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.
  • S Offline
    slbaumgartner
    last edited by 5 Feb 2014, 17:57

    Is there a way to create a button in a toolbar that works like the zoom extents button? That is, when you click it the underlying Tool/Command does its one-shot action and then the Toolbar button returns to un-selected? The only way I've been able to get this effect is to force the model to select the SelectionTool (which isn't necessarily what was active before). I tried things such as popping the active tool, but it didn't reset the button.

    Thanks
    Steve

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 5 Feb 2014, 19:02

      A button should never show it is checked unless YOU set it's validation to anything other than MF_ENABLED || MF_UNCHECKED

      Answer yes, using send_action.

      IF there is a selection then this Zoom command should zoom to the selection, otherwise zoom to the model extents.

      command_proc = {
        if Sketchup.active_model.selection.empty?
          Sketchup.send_action("viewZoomExtents;")
        else
          Sketchup.send_action("viewZoomToSelection;")
        end
      }
      

      💭

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • T Offline
        tt_su
        last edited by 5 Feb 2014, 19:20

        @slbaumgartner said:

        Is there a way to create a button in a toolbar that works like the zoom extents button? That is, when you click it the underlying Tool/Command does its one-shot action and then the Toolbar button returns to un-selected?

        That is the default behaviour, unless you implement validation procs or make the button activate a tool. When you activate a tool the button will remain pressed for as long as that tool is active.

        1 Reply Last reply Reply Quote 0
        • S Offline
          slbaumgartner
          last edited by 5 Feb 2014, 20:22

          @dan you may have missed my point. I don't want to implement a zoom, I was just mentioning zoom extents as a tool whose button does what I want. I have a different tool that isn't really modal, it just performs an action and then wants control to go back to whatever was live before.

          @TT I'm puzzled. Here's what I tried:

          
          tb=UI;;Toolbar.new "Test"
          cmd = UI;;Command.new("clickme") {puts "click!"}
          tb.add_item cmd
          tb.show
          
          

          This works functionally, that is, it prints click! in the Ruby Console, but the button toggles between unselected and selected ("pressed") look with each click. I want it to reset to unselected after each click and reactivate whatever was the active tool before the click.

          Thanks
          Steve

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 6 Feb 2014, 01:13

            Your example works fine for me on PC, in both versions that I have installed (and from memory in all versions I have ever had installed.)

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dan Rathbun
              last edited by 6 Feb 2014, 01:19

              You may have run into a Mac bug in a certain version.

              Try this:

              tb=UI;;Toolbar.new "Test"
              cmd = UI;;Command.new("clickme") {puts "click!"}
              cmd.set_validation_proc { MF_UNCHECKED }
              tb.add_item cmd
              tb.show
              

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • S Offline
                slbaumgartner
                last edited by 6 Feb 2014, 01:24

                @dan rathbun said:

                You may have run into a Mac bug in a certain version.

                Try this:

                tb=UI;;Toolbar.new "Test"
                > cmd = UI;;Command.new("clickme") {puts "click!"}
                > cmd.set_validation_proc { MF_UNCHECKED }
                > tb.add_item cmd
                > tb.show
                

                Tried that in several versions of SU and the button toggles between "unpressed" and "pressed" every time...

                1 Reply Last reply Reply Quote 0
                • D Offline
                  Dan Rathbun
                  last edited by 6 Feb 2014, 01:30

                  Disable all plugins, test again. If still it does not work.. log a bug report.

                  State whether the toolbar is floating, docked vertically, or on the top horizontal bar (which has always been buggy on the Mac.)

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    Dan Rathbun
                    last edited by 6 Feb 2014, 01:31

                    Also verify that MF_UNCHECKED == 0, just to be sure no plugin has messed with the global constants.

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      slbaumgartner
                      last edited by 6 Feb 2014, 01:36

                      @dan rathbun said:

                      Disable all plugins, test again. If still it does not work.. log a bug report.

                      State whether the toolbar is floating, docked vertically, or on the top horizontal bar (which has always been buggy on the Mac.)

                      Still doesn't work, whether floating, docked, or in the top bar. Filing a bug.

                      Steve

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        tt_su
                        last edited by 6 Feb 2014, 09:31

                        Oh, right - yes I noticed that there's a bug under OSX. Sorry, I mostly use PC so I'd forgotten. I think there's an issue for it, but I'll check again and bump it.

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

                        Advertisement