sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Toolbar Icon checked_unchecked

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 4 Posters 272 Views 4 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.
    • G Offline
      Gultekinmg
      last edited by

      I have been trying to create toolbars auto closed when a tool item selected,
      If Toolbar is checked "off" at my array holds toolbar names.
      First item of a toolbar is used to mark this toolbar off/on at array.
      Thou.. My code works;..
      I have seen that validation process cause endless loop at my code and other validation procs used.
      Any better simple and safe code pleases?

      
      #localized instance vars. 
      toolbar_name = @cmdstbname 
      toolbar_look =  @cmdsubtoolbar 
      toolbar_check =   @checkstbar 
      check_no =      @checkindex 
      cmd = UI;;Command.new("Fixpanel_"+toolbar_name) { 
              if @txtoolbar_name_array[check_no][2] == "off" 
                 @txtoolbar_name_array[check_no][2]= "on" 
                 Sketchup.status_text = " (#{toolbar_name}) Panel Pinned no auto- 
      close when a tool selected." 
              else 
                 @txtoolbar_name_array[check_no][2]= "off" 
                 Sketchup.status_text = "(#{toolbar_name})  Panel tempered to auto- 
      close." 
              end 
              } 
      cmd.small_icon = "../images/ruby_favorite_SM.png" 
      cmd.large_icon = "../images/ruby_favorite_LG.png" 
      cmd.tooltip =  " Pin (#{toolbar_name}) Panel" 
      cmd.status_bar_text =  " Pin (#{toolbar_name}) Panel" 
      cmd.menu_text = " Pin (#{toolbar_name}) Panel" 
      cmd.set_validation_proc { 
      p {check_no} 
        if @txtoolbar_name_array[check_no][2]== "on" 
              MF_CHECKED 
        else 
          MF_UNCHECKED 
        end 
      } 
      
      @cmd = cmd  # add cmd.item to toolbar 
      ##### or ####
      def check_validation_proc(check_no)
      p {check_no}
        if @txtoolbar_name_array[check_no][2]== "on" 
              return MF_CHECKED 
        else 
          return MF_UNCHECKED 
        end 
      end 
      cmd.set_validation_proc { check_validation_proc(check_no) } 
      
      

      Beware: Jim.Foltz ToolBar 2010 does same loop. if you inject - p "this is bug." - in 'toggleperspective.rb' you'll see this.
      it repeats till toolbar closed.

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

        Validation procs are evaluated extremly frequently - ensure they do as little as possible.

        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

          Do not use Custom Toolbars as an example for creating toolbars - it uses unconventional techniques that won't make sense outside of Custom Toolbars (i.e. @cmd = cmd)

          In your example, you have defined the validation proc twice. Also, calling "return" from a proc doesn't make sense - when the proc exits, the value MF_CHECKED is returned implicitly.

          Hi

          1 Reply Last reply Reply Quote 0
          • G Offline
            Gultekinmg
            last edited by

            @jim said:

            In your example, you have defined the validation proc twice. Also, calling "return" from a proc doesn't make sense - when the proc exits, the value MF_CHECKED is returned implicitly.

            Thx. jim. i did not use twice. but, sampled it here that your code also makes infinite loop as i have install at GSU8m2.
            I need help to over come this. But Thom say do not use it. no solution for this?

            I have been testing my "Clean DeskTOP.rb" plugin to simulate menus on toolbar build on Jim Foltz Toolbar plugin. very close to post here. but i have no idea about copyrights that i could develop on his plugin. May i?
            sample. Clean DeskTOP.
            CleanDeskTOP.gif

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              OK, I viewed this topic (per request,) and I do not have anything more to add to what Thomas and Jim have said.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • G Offline
                Gultekinmg
                last edited by

                @dan rathbun said:

                OK, I viewed this topic (per request,) and I do not have anything more to add to what Thomas and Jim have said.

                Ok. I am closing this thread with following conclusion.

                As far as i understand after examining all codes on toolbar and menu validation,"MF_" validation cause implicite loop at menu and toolbar handling to lower SU GUI-process.
                Since, most of SU-Toolbars use that validation procs they cost process time while they are open at your desktop.
                it might be why SU-menus autoclose. Since, we can't handle SU custom toolbars, we dont see how they are flouding on screen.
                I wonder why they use "MF_" validation at Toolbars, if it is Menu associated.
                That could be a reason for me to develop "Clean DESKTOP" plugin to organize Toolbars as "PS" utilizes.

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

                  I do not think there is an infinite loop - the repeating output is because the validation proc is being called by SketchUp very frequently.

                  @gultekinmg said:

                  i have no idea about copyrights that i could develop on his plugin. May i?

                  Sure. I like the idea of disappearing toolbars.

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • G Offline
                    Gultekinmg
                    last edited by

                    @jim said:

                    I do not think there is an infinite loop - the repeating output is because the validation proc is being called by SketchUp very frequently.

                    frequently as much they MF_check, MF_unchek toolbar items. As long as CustomToolbars are open i guess they are repeading output.

                    @jim said:

                    Sure. I like the idea of disappearing toolbars.

                    Mercy, Jim. I'll post free for noel. I hope you customize it as you like it. All yours.

                    I'll drop item.cmd validation from code. sry that.๐Ÿ˜ž

                    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