sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Update | Sketchucation Tools 5.0.8 released with licensing improvements and bugfixes Download

    WebDialog input text and the single quote.

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 720 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.
    • sdmitchS
      sdmitch
      last edited by

      Is there some reason that a single quote can not be used in a input text box in a webdialog?

      I was working on a WebDialog and attempted to enter a value in feet rather than inches but got an error due to the data string from a submit button being empty. It seems that 60" is ok but 5' isn't. However 5' is ok.

      The following code can be used to demonstrate.

      def webdialog()
       @dlg=UI;;WebDialog.new("TESTING", false,"WDID",300,200,10,10,true)
       @dlg.set_html(
        "<html>
         <body>
          <form action='skp;wd_data@'>
           <input type='text' name='tb1' value='60' size=1 > TextBox One</input><br>
           <input type='submit' name='submit' value='Go' />
          </form>
         </body>
        </html>"
       )
          
       RUBY_PLATFORM =~ /(darwin)/ ? @dlg.show_modal() ; @dlg.show()
          
       @dlg.add_action_callback("wd_data") {|d,p|
        if p
         puts p
        else
         puts "p was empty"
        end
       }
      end
      
      

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply
      Reply Quote 0
      • A
        Anton_S
        last edited by

        The reason you can't use ' is because its an escape character in your string:
        Whenever you wan't to get element value, use dlg.get_element_value('element_id') It handles escape characters like a charm.

        So, if want to get your element value whenever "ws_data" is called, do this:

        <span class="syntaxdefault"><br /></span><span class="syntaxkeyword">@</span><span class="syntaxdefault">dlg</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_action_callback</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"wd_data"</span><span class="syntaxkeyword">){</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">d</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">p</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">  text </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> d</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_element_value</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'tb1'</span><span class="syntaxkeyword">)<br />}&nbsp;</span><span class="syntaxdefault"></span>
        

        Make sure to avoid passing text value to the callback; this will prevent the error.

        1 Reply Last reply
        Reply Quote 0
        • sdmitchS
          sdmitch
          last edited by

          Thanks Anton, that does work. Early on I had problems using .get_element_value so I never thought about it again opting to get the values from the "p" string. I guess it was just beginners bad luck.

          Nothing is worthless, it can always be used as a bad example.

          http://sdmitch.blogspot.com/

          1 Reply Last reply
          Reply Quote 0
          • tt_suT
            tt_su
            last edited by

            @sdmitch said:

            Early on I had problems using .get_element_value so I never thought about it again opting to get the values from the "p" string.

            What problem was that?
            I also utilize get_element_value for callbacks from JS to Ruby. I use a bridge that convert basic Ruby and JS objects back and forth with synchronous callback on both platform. Using an input element as data transfer is my standard technique.

            1 Reply Last reply
            Reply Quote 0
            • sdmitchS
              sdmitch
              last edited by

              @tt_su said:

              @sdmitch said:

              Early on I had problems using .get_element_value so I never thought about it again opting to get the values from the "p" string.

              What problem was that?
              I also utilize get_element_value for callbacks from JS to Ruby. I use a bridge that convert basic Ruby and JS objects back and forth with synchronous callback on both platform. Using an input element as data transfer is my standard technique.

              It was very early in my plugin career and involved radio buttons. As soon as I found something else that worked, I never tried using it again. I'm sure it was mostly, if not all, operator error.

              Nothing is worthless, it can always be used as a bad example.

              http://sdmitch.blogspot.com/

              1 Reply Last reply
              Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement