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

    [solved] a simple UI.inputbox problem

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 353 Views 2 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.
    • artmusicstudioA Offline
      artmusicstudio
      last edited by artmusicstudio

      hi,
      just a simple UI.inputbox-problem:

      why does this simple method not work?

      
      #***************************************************************************
      def one_value_input
      #***************************************************************************
      get_single_value ["a"],["b"],["c"]
      end#def
      
      #***************************************************************************
      def get_single_value (prompts, defaults, headline)
      #***************************************************************************
      
      puts prompts #>>> puts a
      puts defaults #>>> puts b
      puts headline #>>> puts c
      input = UI.inputbox(prompts,defaults,headline)
      end#def
      
      

      the picture shows, what comes from it....no idea, why ! (and the "c" appears in the pulldown ....

      thanx
      stan


      xxx.png

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

        An inputbox takes three OR four arguments.
        promptarray, valuearray, popsarray, titlestring
        The first two arguments must always be arrays.
        The first one contains string elements used as the prompts.
        The second one can contain various elements - string ["cat"], float [1.2], integer [6], length [25.mm]
        There must be a third argument of some kind.
        If you pass the third element as an array you can get a drop-down if you pass a non-empty string.
        If the default value is NOT on the passed list-string then it'll start with a 'blank'.
        If you pass three arguments and the third is a simple string, then that is used as a 'title'.

        I your case with a one item inputbox:

        results = inputbox(["Choose Item: "], ["a"], ["a|b|c|d|e"])

        gives a fixed list to choose from ('a' to 'e', defaulting at 'a') BUT NO 'title' [since you pass NO string].
        Note how the elements of the drop-down list are separated by '|'...

        Whereas:

        results = inputbox(["Type in a String: "], ["?"], "Title")

        gives an inputbox expecting a string to be typed NOT chosen, with the default of '?'

        To complete the permutations and extend the example a little, this example below gives you a two item inputbox, expecting a typed in response AND list to choose from, and a also has a 'title':

        results = inputbox(["Typed: ", "Chosen: "], ["?", "a"], ["", "a|b|c|d|e"], "Title")

        To get the results into two variables ('typed' and 'chosen') use:
        return nil unless results ### in case user Cancels! typed,chosen = results

        TIG

        1 Reply Last reply Reply Quote 0
        • artmusicstudioA Offline
          artmusicstudio
          last edited by

          hi tig,
          understood and done, works perfect,
          the combi-version is very nice and confortable and i can pass arguments to it from any method.
          you will then see it in the finished ruby!
          thanx a lot for the explanation.
          stan

          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