Inputbox prompt strings are clipped short without apparent reason

the whole thing is very weird, it seems I only need padding on the end of the last prompt…

and another…

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

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.

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

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.

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…

  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

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!!!)

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)

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

    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

this last ones getting cropped…

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.

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(??)

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)

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 (3.0 MB)

john

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?

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.

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

john

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…

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.

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

that prompt gets chomped on a mac…

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

Here are a few:

Here’s one where I show allowable ranges on left and prompt justified on the right.

But if you enter invalid stuff I return with

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

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

Here is another quirk with the Windows inputbox:

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

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