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

    VCB and Shortcut Keys

    Scheduled Pinned Locked Moved Developers' Forum
    34 Posts 6 Posters 3.3k Views 6 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.
    • ChiefwoodworkerC Offline
      Chiefwoodworker
      last edited by

      @thomthom said:

      I cannot reproduce this...

      
      > class MyTool; end;
      > Sketchup.active_model.select_tool( MyTool.new )
      > 
      

      Any chance you've already loaded the code with enableVCB? ? Because then commenting out will not remove it if you reload the file.

      Here is the sequence on my Windows PC.

      1. Comment out the enableVCB? method.
      2. Open SketchUp.
      3. Open my model.
      4. Select my tool.
      5. Pick first point.
      6. Type a number into the VCB with no characters.
      7. Press Enter and the number is interpreted as a length by my conversion code.

      I can repeat this sequence with only steps 6 and 7 changed.
      6. Type a number followed by t, no space, and the Tape Measure tool come up.
      7. Never get to step 7.

      If I repeat the sequence using s in step 6. instead of t I get a system beep indicating the input can't be parsed (I don't have the code in there to parse an s).

      Now I repeat these same three tests with the enableVCB? method coded to return true. Note I completely close SketchUp, make the code change and Re-Open SketchUp. I Don't use reload.

      I get exactly the same results as with no enableVCB? method. Further, as I mentioned earlier, if I code the enableVCB? method as follows:

      def enableVCB? UI.beep return true end

      I never get a beep on any keystroke. But I do with left mouse button presses (and I believe left mouse button up as well). There is a bug here someplace but I am not sure how it should work. I know how I would like it to work, but that is probably not interesting to the SketchUp team.

      p.s. I get the same behavior on SketchUp Pro 8.
      p.p.s. I have a friend who wrote a tool script and never knew about enableVCB? method, hence never implemented it. His tool worked as long as what he typed into the VCB was numbers and no characters. If confirmed for me that he gets the same results I do when he uses a shortcut key. He then implemented the enableVCB? method to return true and also got the same results.

      Joe....
      http://www.srww.com

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

        I'm puzzled that you can get a tool to accept VCB input if enableVCB? is not implemented... did you try my bare bone example?
        What Windows version do you have?

        And I don't think that enableVCB? is meant to be called on each key stroke.

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

        1 Reply Last reply Reply Quote 0
        • ChiefwoodworkerC Offline
          Chiefwoodworker
          last edited by

          @thomthom said:

          I'm puzzled that you can get a tool to accept VCB input if enableVCB? is not implemented... did you try my bare bone example?

          I modified your example as follows:

          class MyTool def onUserText(text, view) begin value = text.to_l #just to do something rescue # Error parsing the text UI.beep puts "Cannot convert #{text} to a Length" value = nil Sketchup::set_status_text "", SB_VCB_VALUE end return if !value UI.messagebox(text) end end; Sketchup.active_model.select_tool( MyTool.new )

          I typed 36 into the VCB and hit Enter. Resulting output is shown in image at bottom.

          @thomthom said:

          What Windows version do you have?

          Windows 8 64 bit.

          @thomthom said:

          And I don't think that enableVCB? is meant to be called on each key stroke.

          Well, if it is supposed to allow and check for accepted characters besides numerals I would think it would have to. But it should at least be called on Enter and it isn't.


          mytool_output.jpg

          Joe....
          http://www.srww.com

          1 Reply Last reply Reply Quote 0
          • ChiefwoodworkerC Offline
            Chiefwoodworker
            last edited by

            @tig said:

            The excepted characters that are OK after a number are:
            ",',m,mm,cm,s,x,/,*,[,],<,> etc
            Can you use some of those in your custom inputs...

            TIG,

            Where in the documentation did you find this list of accepted characters after a numeral? I haven't been able to locate it.

            Joe....
            http://www.srww.com

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              It doesn't exist...
              Just made it up - from what I know works... 😉

              TIG

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

                That's interesting. Just making use of onUserText will enable the VCB - making enableVCB? redundant. (Though this might need testing on all versions - in case this is something that has changed.)
                I don't see the point of enableVCB? if onUserText automatically enables it...

                @chiefwoodworker said:

                Well, if it is supposed to allow and check for accepted characters besides numerals I would think it would have to. But it should at least be called on Enter and it isn't.

                It's only a simple property to enable or disable the VCB.
                The docs only says:

                The enableVCB? method is used to tell SketchUp whether to allow the user to enter text into the VCB (value control box, aka the "measurements" panel). If you do not implement this method, then the vcb is disabled by default.
                

                So it doesn't affect what types of characters you can input - it just enables/disables the control as a whole.

                But I agree that there should be a way to prevent keyboard shortcuts from triggering.

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

                1 Reply Last reply Reply Quote 0
                • ChiefwoodworkerC Offline
                  Chiefwoodworker
                  last edited by

                  @tig said:

                  It doesn't exist...
                  Just made it up - from what I know works... 😉

                  I like your style 😉

                  Joe....
                  http://www.srww.com

                  1 Reply Last reply Reply Quote 0
                  • ChiefwoodworkerC Offline
                    Chiefwoodworker
                    last edited by

                    @thomthom said:

                    It's only a simple property to enable or disable the VCB.
                    The docs only says:

                    The enableVCB? method is used to tell SketchUp whether to allow the user to enter text into the VCB (value control box, aka the "measurements" panel). If you do not implement this method, then the vcb is disabled by default.
                    

                    So it doesn't affect what types of characters you can input - it just enables/disables the control as a whole.

                    I don't think it is the onUserText that is enabling the VCB. I think the default is true, not false. Try this script:

                    class MyTool def enableVCB? UI.beep end end; Sketchup.active_model.select_tool( MyTool.new )

                    Depress and release the left mouse button slowly. You will see that enableVCB? is called on both the down and up of the left mouse button. That's why I think it is intended to sample each key stroke, to see if a shortcut key was preceded by a number, in which case it would be interpreted as a parameter of the number and not a shortcut key. But it doesn't get called at all with a key stroke, including the Enter key, which I think is the bug. Why is it called with a mouse action? That's what's curious to me.

                    Joe....
                    http://www.srww.com

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

                      I asked the SketchUp team, and they confirmed that onUserText enables the VCB - and enableVCB? is there to let you disable the VCB when you do not want user input. (For instance - if your tool uses the VCB to adjust values then you don't want the VCB to be enabled until you have performed an action.)

                      And enableVCB? is queried on certain event which one can assume the tool changes state - such as on mouse clicks.

                      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

                        I looked further at the behaviour of the Tool class - using variations of this snippet to inspect the behaviour:

                        <span class="syntaxdefault"><br />class ToolTest6<br /><br />  </span><span class="syntaxkeyword">%</span><span class="syntaxdefault">w</span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">    activate<br />    deactivate<br />    Xdraw<br />    enableVCB</span><span class="syntaxkeyword">?<br /></span><span class="syntaxdefault">    getExtents<br />    getInstructorContentDirectory<br />    getMenu<br />    onCancel<br />    onKeyDown<br />    onKeyUp<br />    onLButtonDoubleClick<br />    onLButtonDown<br />    onLButtonUp<br />    onMButtonDoubleClick<br />    onMButtonDown<br />    onMButtonUp<br />    onMouseEnter<br />    onMouseLeave<br />    XonMouseMove<br />    onRButtonDoubleClick<br />    onRButtonDown<br />    onRButtonUp<br />    onReturn<br />    XonSetCursor<br />    onUserText<br />    resume<br />    suspend<br />  </span><span class="syntaxkeyword">}.</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">event_name</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">    define_method</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> event_name </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">|*</span><span class="syntaxdefault">args</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">      puts event_name<br />      true<br />    </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">  </span><span class="syntaxkeyword">}<br /><br /></span><span class="syntaxdefault">  </span><span class="syntaxkeyword">%</span><span class="syntaxdefault">w</span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">    onKeyDown<br />    onKeyUp<br />  </span><span class="syntaxkeyword">}.</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">event_name</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">    define_method</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> event_name </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">|*</span><span class="syntaxdefault">args</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">      puts event_name<br />      false<br />    </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">  </span><span class="syntaxkeyword">}<br /><br /></span><span class="syntaxdefault">end </span><span class="syntaxcomment"># class<br /><br /></span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">select_tool</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> ToolTest6</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">new </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span>
                        

                        Not the X in front of some names - I used that to quickly prevent some events from flooding the console.

                        Here's a quick summary of which event triggered which was followed by enableVCB?:

                        ` activate
                        enableVCB?

                        onMouseEnter

                        onMouseLeave

                        onLButtonDown
                        enableVCB?

                        onLButtonUp
                        enableVCB?

                        onLButtonDoubleClick
                        enableVCB?

                        onMButtonDown

                        onMButtonUp

                        onRButtonDown
                        enableVCB?

                        onRButtonUp

                        onRButtonDoubleClick

                        onKeyDown

                        onKeyUp

                        onUserText

                        onReturn
                        enableVCB?`

                        The event's that responded with enableVCB? query:
                        activate onLButtonDown onLButtonUp onLButtonDoubleClick onRButtonDown onReturn

                        Other observations:
                        If onKeyDown or onKeyUp return true then no text is entered into the VCB. It appear to block it.

                        When the VCB is enabled: Space, S, M, K etc didn't trigger it's shortcuts - but only if I had typed a number first.

                        If the VCB is enabled, and you enter some input to the VCB then first onUserText will trigger the first time you hit Return - then on the second you hit Return onReturn will trigger.

                        If the VCB is disabled then onReturn will trigger every time you hit Return.

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

                        1 Reply Last reply Reply Quote 0
                        • ChiefwoodworkerC Offline
                          Chiefwoodworker
                          last edited by

                          @thomthom said:

                          I asked the SketchUp team, and they confirmed that onUserText enables the VCB - and enableVCB? is there to let you disable the VCB when you do not want user input. (For instance - if your tool uses the VCB to adjust values then you don't want the VCB to be enabled until you have performed an action.)

                          And enableVCB? is queried on certain event which one can assume the tool changes state - such as on mouse clicks.

                          thomthom,

                          Thanks very much for the help on this and clearing things up. The documentation on this is really poor and misleading. I still wish we had a way to disable shortcut keys like the native tools have.

                          Thanks again.

                          Joe....
                          http://www.srww.com

                          1 Reply Last reply Reply Quote 0
                          • ChiefwoodworkerC Offline
                            Chiefwoodworker
                            last edited by

                            @thomthom said:

                            I looked further at the behaviour of the Tool class - using variations of this snippet to inspect the behaviour:

                            thomthom,

                            Your help is well above and beyond anything I could ask for. Thanks again. I am loading the snippet to complete the "etc" and see if there are keys I can use.

                            Joe....
                            http://www.srww.com

                            1 Reply Last reply Reply Quote 0
                            • D Offline
                              driven
                              last edited by

                              Hi Joe,
                              your script partially works on mac with to_f added @ line 4.
                              jumps out of tool if you hit a   q t o p a f h l
                              a lot of Capitals work as well, e.g LBWH all work, as a block or on their own...

                              
                              value = text.to_f.to_l #<<ADDED  TO FLOAT
                              
                              

                              john

                              learn from the mistakes of others, you may not live long enough to make them all yourself...

                              1 Reply Last reply Reply Quote 0
                              • ChiefwoodworkerC Offline
                                Chiefwoodworker
                                last edited by

                                @driven said:

                                Hi Joe,
                                your script partially works on mac with to_f added @ line 4.

                                Interesting John. On my Windows PC I modified the script as follows:

                                <span class="syntaxdefault">def onUserText</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">text</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> view</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Text is a #{text.class} class."</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    begin<br />      value </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> text</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_l<br />      puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Value is a #{value.class} class."</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    rescue<br />      </span><span class="syntaxcomment"># Error parsing the text<br /></span><span class="syntaxdefault">      UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">beep<br />      puts </span><span class="syntaxstring">"Cannot convert #{text} to a Length"<br /></span><span class="syntaxdefault">      value </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> nil<br />      Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">set_status_text </span><span class="syntaxstring">""</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> SB_VCB_VALUE<br />    end<br />    return if </span><span class="syntaxkeyword">!</span><span class="syntaxdefault">value<br />    if </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">state </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> 1 and </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">stick_pt2</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">valid</span><span class="syntaxkeyword">?<br /></span><span class="syntaxdefault">      build_story_stick</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">true</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> value</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">      new_stick<br />    end<br />  end</span>
                                

                                and get the following puts to the console. No complaints of coercing String to Length.

                                Text is a String class.
                                Value is a Length class.

                                But your code is clearly more correct and you may have saved me a Mac bug. Very interesting that it works on the PC but not the Mac.

                                Joe....
                                http://www.srww.com

                                1 Reply Last reply Reply Quote 0
                                • ChiefwoodworkerC Offline
                                  Chiefwoodworker
                                  last edited by

                                  @chiefwoodworker said:

                                  But your code is clearly more correct and you may have saved me a Mac bug. Very interesting that it works on the PC but not the Mac.

                                  Whoops! Let me correct myself. SketchUp has a String def called to_l so the you don't need the to_f. Are you sure it doesn't work without the to_f?

                                  Joe....
                                  http://www.srww.com

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    driven
                                    last edited by

                                    with your original code, I get
                                    Cannot convert 1w to a Length
                                    if I change only this line

                                    value = text.to_f.to_l #just to do something
                                    

                                    I get 1w in the message box...

                                    with your last code I get an empty message box, with or without the .to_f

                                    john

                                    learn from the mistakes of others, you may not live long enough to make them all yourself...

                                    1 Reply Last reply Reply Quote 0
                                    • S Offline
                                      slbaumgartner
                                      last edited by

                                      Ya gotta love it! The following works just fine on the Mac, even though h is the shortcut for the pan tool, but fails on Windows by switching to pan.

                                      <span class="syntaxdefault"></span><span class="syntaxkeyword">class&nbsp;</span><span class="syntaxdefault">MyTool<br />&nbsp;&nbsp;def&nbsp;onUserText</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rawtext</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">view</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">begin<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">messagebox</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"VCB&nbsp;held&nbsp;#{rawtext}"</span><span class="syntaxkeyword">)&nbsp;</span><span class="syntaxcomment">#&nbsp;show&nbsp;the&nbsp;raw&nbsp;input<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">if(</span><span class="syntaxdefault">rawtext</span><span class="syntaxkeyword">[-</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">chr&nbsp;</span><span class="syntaxkeyword">=~&nbsp;/[</span><span class="syntaxdefault">wh</span><span class="syntaxkeyword">]/)&nbsp;</span><span class="syntaxcomment">#trap&nbsp;and&nbsp;strip&nbsp;key&nbsp;characters&nbsp;if&nbsp;present<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">key&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">rawtext</span><span class="syntaxkeyword">[-</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">chr<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">rawtext</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">chop</span><span class="syntaxkeyword">!<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">text&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">rawtext<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">text</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_l&nbsp;</span><span class="syntaxcomment">#see&nbsp;if&nbsp;text&nbsp;is&nbsp;convertible&nbsp;to&nbsp;a&nbsp;length<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">rescue<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;can't&nbsp;process&nbsp;the&nbsp;VCB&nbsp;input.&nbsp;&nbsp;This&nbsp;could&nbsp;be&nbsp;because&nbsp;the&nbsp;trailing&nbsp;character<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;isn't&nbsp;one&nbsp;of&nbsp;the&nbsp;key&nbsp;characters&nbsp;or&nbsp;because&nbsp;the&nbsp;text&nbsp;isn't&nbsp;a&nbsp;number<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">beep<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;</span><span class="syntaxstring">"Cannot&nbsp;convert&nbsp;#{rawtext}&nbsp;to&nbsp;Length&nbsp;with&nbsp;optional&nbsp;key"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">value&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">nil<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">set_status_text&nbsp;</span><span class="syntaxstring">""</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">SB_VCB_VALUE<br />&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">return&nbsp;if&nbsp;!</span><span class="syntaxdefault">value<br />&nbsp;&nbsp;&nbsp;&nbsp;UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">messagebox</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Got&nbsp;value&nbsp;=&nbsp;#{value},&nbsp;key&nbsp;=&nbsp;#{key}"</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">end<br />end<br />Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">select_tool</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">MyTool</span><span class="syntaxkeyword">.new&nbsp;)&nbsp;</span><span class="syntaxdefault"></span>
                                      

                                      Steve

                                      1 Reply Last reply Reply Quote 0
                                      • TIGT Offline
                                        TIG Moderator
                                        last edited by

                                        Why not take your normal 'numbers' text as your lengths, and then use key-down checks for toggling what it means ?
                                        Like Cmd/Ctrl, Shift etc *** - so on one press of that key it expects one type of value [shown in status-bar] on the next press it's something else = i.e. it's a 'toggle'.

                                        ***You can use TAB key action as a toggle BUT it must be key-up as the MAC doesn't recognize tab-down - only tab-up !

                                        TIG

                                        1 Reply Last reply Reply Quote 0
                                        • ChiefwoodworkerC Offline
                                          Chiefwoodworker
                                          last edited by

                                          @tig said:

                                          Why not take your normal 'numbers' text as your lengths, and then use key-down checks for toggling what it means ?
                                          Like Cmd/Ctrl, Shift etc *** - so on one press of that key it expects one type of value [shown in status-bar] on the next press it's something else = i.e. it's a 'toggle'.

                                          ***You can use TAB key action as a toggle BUT it must be key-up as the MAC doesn't recognize tab-down - only tab-up !

                                          Hi TIG,

                                          That is exactly what I will end up doing in my tool. So as far as I am concerned I have a solution to the problem I raised, thanks to the folks like you who responded to my original question.

                                          However, I think the bigger issue here is that there are scripts in this thread that work on the Mac and not the PC, and scripts that work on the PC and not the Mac. Apparently the Mac is not aware of the String class to_l method and the PC doesn't handle the h shortcut key correctly. Although I would argue that the PC is handling the h shortcut key the way I would like it to and the PC and Mac are handling shortcut keys when they shouldn't be if the VCB is active for user input.

                                          I for one just wish that release 2013 spent more time on bug fixes, platform inconsistencies and Ruby API maintenance than it did on icon changes which are driving me nuts and causing me a lot of work.

                                          But again, thank you and the others who helped me on this issue.

                                          Joe....
                                          http://www.srww.com

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

                                            @driven said:

                                            with your original code, I get
                                            Cannot convert 1w to a Length
                                            if I change only this line

                                            value = text.to_f.to_l #just to do something
                                            

                                            I get 1w in the message box...

                                            with your last code I get an empty message box, with or without the .to_f

                                            john

                                            What should "1w" represent?

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

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

                                            Advertisement