cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
SDF1
Super User

JSL: How to change the width of a combo box

Hi All,

 

  I am working on some JSL code where I have some combo boxes listed in a V List Box(); The lists for the combo boxes are all of different character lengths, but I'd like the combo boxes to all have the same width.

 

  The normal <<Set Width() call doesn't seem to work as expected. I could go in and manually change the character widths by padding the right of each item in each list with spaces, but that seems rather inefficient.

 

  Tried looking this one up, but most discussions are about Text Boxes() or other similar items, not Combo Boxes().

 

  Any suggestions help.

 

Thanks!,

DS

2 ACCEPTED SOLUTIONS

Accepted Solutions
ErraticAttack
Level VI

Re: JSL: How to change the width of a combo box

The builtin LineupBox is designed just for this case, example:

 

Names Default To Here( 1 );
New Window( "Example",
	Lineup Box( N Col( 1 ), Spacing( 0, 2 ),
		Spacer Box( Size( 120, 0 ) )
	,
		cb = Combo Box(
			{"One", "Two", "Three"},
			selection = cb << GetSelected();
			Print( "Selected: " || selection );
		)
	,
		cb2 = combo box( {"a","b","c"} )
	);
);
Jordan

View solution in original post

SDF1
Super User

Re: JSL: How to change the width of a combo box

Hi @ErraticAttack  and @txnelson ,

 

  Thanks for your quick feedback. I tried the escape characters, but they don't always work as expected due to the difference in character length of the multiple different combo boxes and their entries. I ended up going with @ErraticAttack's solution as the Lineup Box() environment worked perfectly. Now, I'll go back and change my other code because I was using nested H List Box() and V List Box() environments with Spacer Box(Size()) entries to edit the aesthetics of the GUI. The Lineup Box() works great and is pretty easy and intuitive.

 

Thanks for the help!,

DS

View solution in original post

6 REPLIES 6
txnelson
Super User

Re: JSL: How to change the width of a combo box

The Scripting Index for ComboBox shows all messages that can be set.  Width is not one of them.  However I have be able to handle the need by embedding non printable characters.  Here is an example

Names Default To Here( 1 );
New Window( "Example",
	cb = Combo Box(
		{"One\!t", "Two", "Three"},
		selection = cb << GetSelected();
		Print( "Selected: " || selection );
	),
	cb2 = combo box( {"a    \!t","b","c"})
);

txnelson_0-1633984313849.png

 

Jim
ErraticAttack
Level VI

Re: JSL: How to change the width of a combo box

The builtin LineupBox is designed just for this case, example:

 

Names Default To Here( 1 );
New Window( "Example",
	Lineup Box( N Col( 1 ), Spacing( 0, 2 ),
		Spacer Box( Size( 120, 0 ) )
	,
		cb = Combo Box(
			{"One", "Two", "Three"},
			selection = cb << GetSelected();
			Print( "Selected: " || selection );
		)
	,
		cb2 = combo box( {"a","b","c"} )
	);
);
Jordan
SDF1
Super User

Re: JSL: How to change the width of a combo box

Hi @ErraticAttack  and @txnelson ,

 

  Thanks for your quick feedback. I tried the escape characters, but they don't always work as expected due to the difference in character length of the multiple different combo boxes and their entries. I ended up going with @ErraticAttack's solution as the Lineup Box() environment worked perfectly. Now, I'll go back and change my other code because I was using nested H List Box() and V List Box() environments with Spacer Box(Size()) entries to edit the aesthetics of the GUI. The Lineup Box() works great and is pretty easy and intuitive.

 

Thanks for the help!,

DS

nikles
Level VI

Re: JSL: How to change the width of a combo box

Does anyone have any ideas on how to make a combo box narrower instead of wider?  Even if I change the items in my list to single characters only, the combo box width seems to have a mind of its own:

Names Default To Here(1);
New Window("Example",
	cb = Combo Box({"i"})
);
cb << Get Width;

With the example above, the width is 107.  This is way too large for a single letter, in my opinion.  But if I add a "j" to the list, so the list is {"i", "j"}, the width actually gets narrower, and goes to 71.  Anyone know why?  

 

PS: I'm using JMP Pro 17.1.0 and MacOS Ventura 13.4.1.

 

PPS: replying to @txnelson : Question about the scripting index...  The "<< Get Width" command isn't listed under "Item Messages" for Combo Box, but it is listed under "Shared Item Messages".  I've often been confused by this, bc it seems to suggest the user should be able to apply << Get Width to a combo box.  But as discussed here, that doesn't seem to be the case.  If the commands in this "Shared Item Messages" section aren't necessarily able to be used on the display box, what is the meaning behind that section (asking sincerely...I am genuinely curious).  Thanks!

nikles
Level VI

Re: JSL: How to change the width of a combo box

Quick correction to my post.  In the "PPS", I was speaking about the "Set Width" command, not the Get Width.  Get Width seems to work on combo boxes.  Sorry for any confusion.

mmarchandTSI
Level V

Re: JSL: How to change the width of a combo box

The combo box actually does respond to "<<Set Width()" message, but it immediately resets to the width automatically assigned by JMP.  I have not found a way to override this behavior.  Glad Lineup Box exists!

 

Names Default To Here( 1 );
New Window( "test", a = Combo Box( {"i"} ) );
Show( a << Get Width );  //31
a << Set Width( 100 );
Show( a << Get Width );  //100
Wait( .1 );
Show( a << Get Width );  //31

As for the wider Combo Box you are seeing when the list is only {"i"}, that appears to be an operating system issue.  As you can see, I get a width of 31, running Windows 11.