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

    VCB and Shortcut Keys

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    34 貼文 6 Posters 3.3k 瀏覽 6 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • ChiefwoodworkerC 離線
      Chiefwoodworker
      最後由 編輯

      I am wrestling with a problem using the Tool methods. I have a tool where I wish to use the VCB to change some parameters of an object being drawn. For example, when using the Circle tool you can type 60s into the VCB and this changes the number of sides to 60 instead of the default 24.

      In my tool I would like the user to be able to type 6t to change the thickness of a wall or 96h to change its height. In native tools like the Circle an entry of the VCB does not invoke a shortcut key i.e. 60s does not select the Scale tool. But in my tool, even though I have implemented the enableVCB? method, 6t invokes the Tape Measure tool and 96h invokes the Pan tool. I thought enableVCB? was supposed to force SketchUp to listen to the VCB when onReturn is fired, and not the keystroke when depressed.

      Has anyone run into this? Is there something I am missing? I have discovered that I can leave the enableVCB? method out altogether and the VCB works just fine so long as I don't use a shortcut key. It seems to do nothing.

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

      1 條回覆 最後回覆 回覆 引用 0
      • TIGT 離線
        TIG Moderator
        最後由 編輯

        Have you set the enableVCB method to ' return true' ?
        if not if returns ' nil'.

        The VCB/SketchUp is set to respond to shortcut keys from within any other tool.
        BUT if you start the VCB input string with a number then this should not happen.
        So 60s is taken as 60 segments NOT Scale, and 1m as 1 meter NOT Move...
        Numbers ending with a limited number of characters are taken as length units ['/"/m/mm/cm etc] in native tools, and by using .to_l in your tools you can mimic that.

        When the user types 60t is the 60 appearing in the VCB - before the pressing of the ' t' jumps elsewhere?
        Do you ever get to them pressing <enter> ?

        Once you get the input as "60t" you need to parse it...
        To find it's a ' t' type...
        text=~/[Tt]$/
        etc, then
        t=text.float
        to get a number from the input >> 60.0
        OR to use 'current units', perhaps something like
        t=text.float.to_s.to_l >> 60.0cm

        TIG

        1 條回覆 最後回覆 回覆 引用 0
        • ChiefwoodworkerC 離線
          Chiefwoodworker
          最後由 編輯

          @tig said:

          Have you set the enableVCB method to ' return true' ?
          if not if returns ' nil'.

          .......

          When the user types 60t is the 60 appearing in the VCB - before the pressing of the ' t' jumps elsewhere?
          Do you ever get to them pressing <enter> ?

          Thanks for the response TIG. Yes, I have implemented the following:

          # For this tool, allow vcb text entry while the tool is active. def enableVCB? return true end

          just as it appears in the API documentation. If I type 60 followed by Enter everything is fine. If I type 60 and immediately type t upon depressing the t I switch to the Tape Measure tool. I never get to Enter in that case.

          By the way, I modified the enableVCB? method as follows:

          # For this tool, allow vcb text entry while the tool is active. def enableVCB? UI.beep return true end

          and I get a beep whenever I press the left mouse key, but not when I type 60t into the VCB.

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

          1 條回覆 最後回覆 回覆 引用 0
          • TIGT 離線
            TIG Moderator
            最後由 編輯

            Your are using 60**t** + < enter> ?
            And NOT 60 + < enter> then **t** 😕

            If the input is 'shielded' by a preceding number then you should be able to include any trailing letter that would otherwise trigger a Shortcut 😕

            TIG

            1 條回覆 最後回覆 回覆 引用 0
            • thomthomT 離線
              thomthom
              最後由 編輯

              @chiefwoodworker said:

              I thought enableVCB? was supposed to force SketchUp to listen to the VCB when onReturn is fired, and not the keystroke when depressed.

              Unfortunately it doesn't. There are some keys that is accepted, provided it's not the first key to be pressed. But they appear to be hard coded into SketchUp to fit the needs of the native tools. 😞

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

              1 條回覆 最後回覆 回覆 引用 0
              • TIGT 離線
                TIG Moderator
                最後由 編輯

                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

                1 條回覆 最後回覆 回覆 引用 0
                • ChiefwoodworkerC 離線
                  Chiefwoodworker
                  最後由 編輯

                  @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...

                  Unfortunately I don't think s works either; it invokes the Scale tool. The larger problem is that enableVCB? appears to have no effect on the VCB. You can leave this method out altogether and the VCB works the same way, i.e. the default false is not the case. In fact, I have confirmed that SketchUp does not call enableVCB? on any keystroke, including Enter. However, it does call enableVCB? on left mouse button. Go figure!

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

                  1 條回覆 最後回覆 回覆 引用 0
                  • thomthomT 離線
                    thomthom
                    最後由 編輯

                    Without enableVCB? you cannot make VCB input...

                    And I've made use of s in VCB input - but it cannot be the first character to be typed.

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

                    1 條回覆 最後回覆 回覆 引用 0
                    • ChiefwoodworkerC 離線
                      Chiefwoodworker
                      最後由 編輯

                      @thomthom said:

                      Without enableVCB? you cannot make VCB input...

                      And I've made use of s in VCB input - but it cannot be the first character to be typed.

                      I am using SketchUp 2013 Pro Windows version. I can comment enableVCB? out and still enter data through the VCB. However, if I enter 5s it invokes the Scale tool. I haven't tried Make or version 8.

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

                      1 條回覆 最後回覆 回覆 引用 0
                      • TIGT 離線
                        TIG Moderator
                        最後由 編輯

                        @chiefwoodworker said:

                        @thomthom said:

                        Without enableVCB? you cannot make VCB input...

                        And I've made use of s in VCB input - but it cannot be the first character to be typed.

                        I am using SketchUp 2013 Pro Windows version. I can comment enableVCB? out and still enter data through the VCB. However, if I enter 5s it invokes the Scale tool. I haven't tried Make or version 8.
                        In my 2d tools the user can type say 12s to change the segmentation of arcs/circles etc just like the native-tools, typing 12s+<enter> does NOT invoke the Scale tool in v8 OR v2013...
                        I have just retested it to make sure.
                        Perhaps there is something adrift in the way you are making your 'Tool' ?
                        Do you have it setup and made as a tool-command as required ?

                        TIG

                        1 條回覆 最後回覆 回覆 引用 0
                        • thomthomT 離線
                          thomthom
                          最後由 編輯

                          @chiefwoodworker said:

                          I am using SketchUp 2013 Pro Windows version. I can comment enableVCB? out and still enter data through the VCB.

                          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.

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

                          1 條回覆 最後回覆 回覆 引用 0
                          • ChiefwoodworkerC 離線
                            Chiefwoodworker
                            最後由 編輯

                            @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 條回覆 最後回覆 回覆 引用 0
                            • thomthomT 離線
                              thomthom
                              最後由 編輯

                              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 條回覆 最後回覆 回覆 引用 0
                              • ChiefwoodworkerC 離線
                                Chiefwoodworker
                                最後由 編輯

                                @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 條回覆 最後回覆 回覆 引用 0
                                • ChiefwoodworkerC 離線
                                  Chiefwoodworker
                                  最後由 編輯

                                  @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 條回覆 最後回覆 回覆 引用 0
                                  • TIGT 離線
                                    TIG Moderator
                                    最後由 編輯

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

                                    TIG

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • thomthomT 離線
                                      thomthom
                                      最後由 編輯

                                      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 條回覆 最後回覆 回覆 引用 0
                                      • ChiefwoodworkerC 離線
                                        Chiefwoodworker
                                        最後由 編輯

                                        @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 條回覆 最後回覆 回覆 引用 0
                                        • ChiefwoodworkerC 離線
                                          Chiefwoodworker
                                          最後由 編輯

                                          @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 條回覆 最後回覆 回覆 引用 0
                                          • thomthomT 離線
                                            thomthom
                                            最後由 編輯

                                            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 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement