# Inputbox prompt strings are clipped short without apparent reason

**URL:** <https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629>\
**Category:** Ruby API\
**Created:** [May 4, 2016, 7:32pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629 "2016-05-04T19:32:13Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![john\_drivenupthewall](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@john\_drivenupthewall](https://forums.sketchup.com/u/john_drivenupthewall)\
**Post date:** [June 20, 2016, 6:25pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/21 "2016-06-20T18:25:24Z")

</div>

the whole thing is very weird, it seems I only need padding on the end of the last prompt…  
 ![](https://global.discourse-cdn.com/sketchup/original/3X/2/a/2a3a7ea10f363fb3ae73208c8f7c800f448457a6.png)  
and another…  
 ![](https://global.discourse-cdn.com/sketchup/original/3X/6/4/646b49968c21f64aeb1edb68057a04f4e2ff0f38.png)

```ruby
sizexmin = 10.5
sizexmax = 10.5
sizeymin = 20.5
sizeymax = 21.5
sizezmin = 30.5
sizezmax = 30.5

if sizexmin.round(1) == sizexmax.round(1)
	xprompt = "X size is: " + sizexmin.to_l.to_s
	else
	xprompt = "X sizes from " + sizexmin.to_l.to_s + " to " + sizexmax.to_l.to_s
	end
	
	if sizeymin.round(1) == sizeymax.round(1)
	yprompt = "Y size is: " + sizeymin.to_l.to_s
	else
	yprompt = "Y sizes from " + sizeymin.to_l.to_s + " to " + sizeymax.to_l.to_s
	end
	
	if sizezmin.round(1) == sizezmax.round(1)
	p zprompt = (("Z size is: " + sizezmin.to_l.to_s).ljust(43, ' '))
	else
	zprompt = ("Z sizes from " + sizezmin.to_l.to_s + " to " + sizezmax.to_l.to_s).ljust(35, ' ')
	end
	prompts = [xprompt, yprompt, zprompt]
        #set defaults
	defaults = [xprompt.length, yprompt.length, zprompt.length]
        #set list
	list = ["","",""]

        #set title
	titletext = "title"

        #Here is inputbox

	resultinputbox = UI.inputbox(prompts, defaults, list, titletext)

```

who knows why or how…

john

---

<div class="post-metadata">

**Author:** ![john\_mcclenahan](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/john_mcclenahan/32/135377_2.png) [@john\_mcclenahan](https://forums.sketchup.com/u/john_mcclenahan)\
**Post date:** [June 20, 2016, 6:41pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/22 "2016-06-20T18:41:17Z")

</div>

Not free at the moment to check on computer (replying from my phone). But my earlier experience on an iMac (5K retina screen) was that you need padding spaces at the RIGHT hand end of the prompt string, not as you have them, on the left.  
PS  
Or did, in the first code example, not in the second one.

---

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [June 21, 2016, 1:22pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/23 "2016-06-21T13:22:51Z")

</div>

That’s helpful, but I want the text right justified so prompt text is next to each input box.  
So I tested the above using rjust and it works fine on windows.  
What we learned here is the problem seems to only affect MACs.  
I’m borrowing a Mac laptop tonite to test there. But its not retina.  
john\_mcclenahan implies that retina screen works differently???

I’m wondering if I might have to pad with a non blank character like a period or underscore.  
Period works with the 35 and 43 padding but underscore doesn’t. Seems like different characters have different widths

---

<div class="post-metadata">

**Author:** ![john\_mcclenahan](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/john_mcclenahan/32/135377_2.png) [@john\_mcclenahan](https://forums.sketchup.com/u/john_mcclenahan)\
**Post date:** [June 21, 2016, 3:01pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/24 "2016-06-21T15:01:44Z")

</div>

I didn’t mean to imply that the problem is Retina related - but the only Mac I have (or indeed have ever used) does have a Retina 5K screen.

I think I have seen reports in this thread from other Mac users with non-Retina screens of a similar issue.

Will try further experiments in the next day or two if not too late to be useful. But haven’t the time just at the moment.

---

<div class="post-metadata">

**Author:** ![john\_drivenupthewall](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@john\_drivenupthewall](https://forums.sketchup.com/u/john_drivenupthewall)\
**Post date:** [June 21, 2016, 3:38pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/25 "2016-06-21T15:38:49Z")

</div>

I’m on non-retina iMac, and Steve is retina…

the Static text is automatically right justified to the Input box…

the last line of Static text needs to be left justified longer than any other line for the avoid truncation…

maybe a conditional will cover both…

```ruby
  OSX = Sketchup.platform == :platform_osx unless defined? OSX
	prompts = [xprompt.rjust(43, ' '), yprompt.rjust(43, ' '), zprompt.rjust(43, ' ')]
	prompts = [xprompt, yprompt, zprompt.ljust(43, ' ')] if OSX

```

john

---

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [June 21, 2016, 6:47pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/26 "2016-06-21T18:47:16Z")

</div>

I tried a number of things on my borrowed mac. The last field needs to by ljust and padded, but there an overall limit of 25 characters (numeric sized): See the number string currently commented out below. (none of this applies to WIndows!!!)

```auto
sizexmin = 10.5
sizexmax = 1110.5
sizeymin = 20.5
sizeymax = 2110.5
sizezmin = 30.5
sizezmax = 30.5

if sizexmin.round(1) == sizexmax.round(1)
	xprompt = ("X size = " + sizexmin.to_l.to_s)#.ljust(61, %Q-?-)
	else
	xprompt = ("X sizes from " + sizexmin.to_l.to_s + " to " + sizexmax.to_l.to_s)#.ljust(61, %Q-?-)
	end
	
	if sizeymin.round(1) == sizeymax.round(1)
	yprompt = ("Y size = " + sizeymin.to_l.to_s)#.ljust(61, %Q-.-)
	else
	yprompt = ("Y sizes from " + sizeymin.to_l.to_s + " to " + sizeymax.to_l.to_s)#.ljust(61, %Q-.-)
	end
	
	if sizezmin.round(1) == sizezmax.round(1)
	zprompt = ("Z size = " + sizezmin.to_l.to_s).ljust(95, %Q- -)
	else
	zprompt = ("Z sizes from " + sizezmin.to_l.to_s + " to " + sizezmax.to_l.to_s).ljust(95, %Q- -)
	end
    puts xprompt
   puts yprompt
   puts zprompt
   #xprompt = %Q-1234567890123456789012345678901234567890-
	prompts = [xprompt, yprompt, zprompt]
        #set defaults
	defaults = ["","",""]
        #set list
	list = ["","",""]

        #set title
	titletext = "title6789012345678901234567890"

        #Here is inputbox

	resultinputbox = UI.inputbox(prompts, defaults, list, titletext)

```

---

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [June 21, 2016, 6:56pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/28 "2016-06-21T18:56:50Z")

</div>

sorry I thought it was only 2 back quotes. Anyhow were is simplest case:

```ruby
    xprompt = %Q=123456789012345678901234567890=
    yprompt = %Q=123456789012345678901234567890=
    zprompt = %Q=123456789012345678901234567890=
    puts xprompt
   puts yprompt
   puts zprompt
   #xprompt = %Q-1234567890123456789012345678901234567890-
	prompts = [xprompt, yprompt, zprompt]
        #set defaults
	defaults = ["","",""]
        #set list
	list = ["","",""]

        #set title
	titletext = "title6789012345678901234567890"

        #Here is inputbox

	resultinputbox = UI.inputbox(prompts, defaults, list, titletext)

```

Works in win not in mac

---

<div class="post-metadata">

**Author:** ![john\_drivenupthewall](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@john\_drivenupthewall](https://forums.sketchup.com/u/john_drivenupthewall)\
**Post date:** [June 21, 2016, 7:01pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/29 "2016-06-21T19:01:34Z")

</div>

this last ones getting cropped…  
 ![](https://global.discourse-cdn.com/sketchup/original/3X/c/3/c3407193a88bd0d0fd7d16d4df05615223509999.png)

---

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [June 21, 2016, 7:29pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/30 "2016-06-21T19:29:05Z")

</div>

OK I think I figured some of it out

1. it has an overall max length as shown above
2. Also It truncates all characters to the right of the rightmost space character. in certain circumstances.

I removed all spaces from the prompts and tested.  
Spaces become an issue if units are architectural: feet inches and fractions with spaces.

---

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [June 21, 2016, 8:07pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/31 "2016-06-21T20:07:17Z")

</div>

Here’s another try: testing for length of each prompt and padding each to the same total length:  
Seems to work OK, but then in other saces it doesn’t(??)

```ruby
sizexmin = 10.5
sizexmax = 10.5
sizeymin = 222220.5
sizeymax = 222120.5
sizezmin = 332220.5
sizezmax = 33220.5

if sizexmin.round(1) == sizexmax.round(1)
	xprompt = ("X=" + sizexmin.to_l.to_s).tr(%Q- -, %Q-_-)
	else
	xprompt = ("X=" + sizexmin.to_l.to_s + ">" + sizexmax.to_l.to_s).tr(%Q- -, %Q-_-)
	end
	
	if sizeymin.round(1) == sizeymax.round(1)
	yprompt = ("Y=" + sizeymin.to_l.to_s).tr(%Q- -, %Q-_-)
	else
	yprompt = ("Y=" + sizeymin.to_l.to_s + ">" + sizeymax.to_l.to_s).tr(%Q- -, %Q-_-)
	end
	
	if sizezmin.round(1) == sizezmax.round(1)
	zprompt = ("Z=" + sizezmin.to_l.to_s).tr(%Q- -, %Q-_-)
	else
	zprompt = ("Z=" + sizezmin.to_l.to_s + ">" + sizezmax.to_l.to_s).tr(%Q- -, %Q-_-)
	end
    
   maxlength = [xprompt.length, yprompt.length, zprompt.length].max + 25
   xpad = maxlength - xprompt.length
   xprompt = xprompt.ljust(xpad, %Q-_-)
   ypad = maxlength - yprompt.length
   yprompt = yprompt.ljust(ypad, %Q-_-)
   zpad = maxlength - zprompt.length
   zprompt = zprompt.ljust(zpad, %Q-_-)
   
    puts xprompt
   puts yprompt
   puts zprompt
   #xprompt = %Q-1234567890123456789012345678901234567890-
	prompts = [xprompt, yprompt, zprompt]
        #set defaults
	defaults = ["","",""]
        #set list
	list = ["","",""]

        #set title
	titletext = "title6789012345678901234567890"

        #Here is inputbox

	resultinputbox = UI.inputbox(prompts, defaults, list, titletext)

```

---

<div class="post-metadata">

**Author:** ![john\_drivenupthewall](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@john\_drivenupthewall](https://forums.sketchup.com/u/john_drivenupthewall)\
**Post date:** [June 21, 2016, 8:24pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/32 "2016-06-21T20:24:17Z")

</div>

while you have a mac have a look a this plugin of mine I converted to a webDialog…

it should look very similar on your windows box as well…  
[jcb\_sine\_circle.rbz](https://forums.sketchup.com/uploads/short-url/aEp9RIIlTKhLCkFDWelNr2mJmQ2.rbz) (3.0 MB)

john

---

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [June 21, 2016, 8:40pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/33 "2016-06-21T20:40:32Z")

</div>

I know web dialogs look great:  
The issues for me are:

1. learning curve: I have no experience in the language.
2. they seem to have issues with different browsers.
3. I need a quick workaround to update extensions already in the field.

Inputbox is the dumbest but simplest UI I’ve every seen, but for really simple input how could they muck it up so badly. Again works find in windows so I’m blindsided.  
Are there any other undocumented win/mac differences?  
Or am I the first to realize that this bug is a win vs mac issue?

---

<div class="post-metadata">

**Author:** ![slbaumgartner](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/slbaumgartner/32/7302_2.png) [@slbaumgartner](https://forums.sketchup.com/u/slbaumgartner)\
**Post date:** [June 21, 2016, 8:52pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/34 "2016-06-21T20:52:00Z")

</div>

> [@barry\_milliken\_droid](#):
>
> Are there any other undocumented win/mac differences?

There are lots of them, but I can’t tell you about them because that would amount to documenting them!

But seriously, yes, there are differences that one finds out about mainly by extensive searching of this forum and sketchUcation and by examining other authors’ plugin code. Trimble documents essentially none of them.

By the way, I think the max content width in the Inputbox depends on whether the font is proportional or monospaced. I took a brief look at the nib file, and the behavior appears to be from the kind of OS X input field they chose and its configuration. I’ve been off-line the last two weeks, so unable to look into it further or to try out your code.

---

<div class="post-metadata">

**Author:** ![john\_drivenupthewall](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@john\_drivenupthewall](https://forums.sketchup.com/u/john_drivenupthewall)\
**Post date:** [June 21, 2016, 8:54pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/35 "2016-06-21T20:54:57Z")

</div>

@slbaumgartner, which nib file, I can’t find it and have lost all my old code when my HD and backups fried…

john

---

<div class="post-metadata">

**Author:** ![slbaumgartner](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/slbaumgartner/32/7302_2.png) [@slbaumgartner](https://forums.sketchup.com/u/slbaumgartner)\
**Post date:** [June 21, 2016, 9:12pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/36 "2016-06-21T21:12:24Z")

</div>

Dang! I was looking at it before I left on vacation, and now I can’t find it again! I’ll keep looking and let you know…

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [June 21, 2016, 9:12pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/37 "2016-06-21T21:12:24Z")

</div>

> [@barry\_milliken\_droid](#):
>
> Are there any other undocumented win/mac differences?

I think there is a longstanding Windows bug where the width of the input fields are set to the width of the first prompt (or perhaps the longest prompt.)

Testing … yup still there.

```ruby
UI.inputbox(
  ["Please enter your really long stupid text into the following text box: "],
  [""],
  [],
  "Stupid Bug Example"
)

```

---

<div class="post-metadata">

**Author:** ![john\_drivenupthewall](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@john\_drivenupthewall](https://forums.sketchup.com/u/john_drivenupthewall)\
**Post date:** [June 21, 2016, 9:17pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/38 "2016-06-21T21:17:43Z")

</div>

that prompt gets chomped on a mac…

![](https://global.discourse-cdn.com/sketchup/original/3X/d/b/db36bfb0a04c4d1b4948f906c2aef6329c92dac4.png)

---

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [June 21, 2016, 9:31pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/39 "2016-06-21T21:31:50Z")

</div>

I’ve done extensive testing on Windows using input box and have never found any problem:

Here are a few:

 ![](https://global.discourse-cdn.com/sketchup/original/3X/d/6/d656579eaafdf70061613919ec3f8aca7370568f.png)

Here’s one where I show allowable ranges on left and prompt justified on the right.  
 ![](https://global.discourse-cdn.com/sketchup/original/3X/4/6/465d824ff43c8e50c1032c003219ec73698d5cea.png)

But if you enter invalid stuff I return with

 ![](https://global.discourse-cdn.com/sketchup/original/3X/d/b/db408366f95c8656e3d318ca1faaa7b911c852f4.png)

none of this is possible on MAC.  
Windows always works.

---

<div class="post-metadata">

**Author:** ![slbaumgartner](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/slbaumgartner/32/7302_2.png) [@slbaumgartner](https://forums.sketchup.com/u/slbaumgartner)\
**Post date:** [June 21, 2016, 9:52pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/40 "2016-06-21T21:52:37Z")

</div>

Unlike on Windows, the InputBox on the Mac does not resize itself based on the amount of text, instead it clips the text.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [June 21, 2016, 9:59pm UTC](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629/41 "2016-06-21T21:59:39Z")

</div>

Here is another quirk with the Windows inputbox:

![](https://global.discourse-cdn.com/sketchup/original/3X/6/a/6a3cea508d08200107d33dd84361a33f09d55270.png)

In this case the prompt widths are incorrectly set to the input width.  
(And the input width is just a bit too small.)

```ruby
UI.inputbox(
  ["Materials Path: "],
  [File.expand_path("~/Documents/SketchUp/Materials")],
  [],
  "Enter path..."
)

```

[Previous page](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629.md?page=1)

[Next page](https://forums.sketchup.com/t/inputbox-prompt-strings-are-clipped-short-without-apparent-reason/24629.md?page=3)
