Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
James_Hark
Level I

How to modify font size of text inside combo box?

Hello,

 

I was wondering if there was a way to adjust the font size of the text inside a combo box? I've got a list of test parameters inside a combo box for a user to select from, but some of the parameter names are pretty lengthy so I'd like to reduce the font size to try and save space on the screen. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
David_Burnham
Super User

Re: How to modify font size of text inside combo box?

or ... 

replace the combo box with a text box.  Use the text box to show the name of the selected parameter (using a small font).  Next to it, have a "select" button.  Use the button script to launch a new window containing the combo box or list box with the parameter names.  Since it is a separate window with no other content you should be able to display the full length names without any problem); make this window modal and update the text box when the window is closed.

 

Here is some crude code to illustrate the idea:

names default to here(1);

NewWindow("Test",
	BorderBox(top(20),bottom(20),left(20),right(20),
		VListBox(
			TextBox("Selected Parameter",<<setFontStyle("Bold")),
			HListBox(
				here:tb = TextEditBox("parameter name 1",<<enable(0),<<setWidth(130)),
				SpacerBox(size(6,0)),
				ButtonBox("select",
					NewWindow("Select",<<modal,
						<<onCLose(
							here:tb<<setText(cb<<getSelected)
						),
						BorderBox(top(20),bottom(20),left(20),right(20),
							cb = ComboBox({"parameter name 1","parameter name 2"})
						)
					),
					underlinestyle(1)
				)
			)
		)
	)
)

 

-Dave

View solution in original post

6 REPLIES 6
Highlighted
txnelson
Super User

Re: How to modify font size of text inside combo box?

I do not find any messages that can be passed to a Combo Box() to set the font size. Therefore I assume that it is following the size of one of the font categories in the Preferences. I did an incomplete search of the Fonts in Preferences, but did not find one that reset the font size for the Combo Box().
Jim
Highlighted
David_Burnham
Super User

Re: How to modify font size of text inside combo box?

I don't think you have the ability to change the font on a combo box.  Perhaps you could implement some logic to shorten the names?

 

// example 1

str = "this is a long parameter name";
if (length(str)>15,
	newstr = left(str,5) || "..." || right(str,5)
);
// newstr = "this ... name"

// example 2

abbreviatedFilePath = function({path},{default local},
    delim = "/";
    If (contains(path,"\"),
        delim = "\"
    );
    lstWords = words(path,delim);
    nwords = nItems(lstWords);
    If (nWords>2,
        abbrPath = "..." || delim || lstWords[nwords-1] || delim || lstWords[nwords]
    ,
        abbrPath = path
    );
    return(abbrPath);
);
str = "c:\this\is_a\long\filepath.txt";
newstr = abbreviatedFilePath(str);
// newsttr = "...\long\filepath.txt"
-Dave
Highlighted
David_Burnham
Super User

Re: How to modify font size of text inside combo box?

or ... 

replace the combo box with a text box.  Use the text box to show the name of the selected parameter (using a small font).  Next to it, have a "select" button.  Use the button script to launch a new window containing the combo box or list box with the parameter names.  Since it is a separate window with no other content you should be able to display the full length names without any problem); make this window modal and update the text box when the window is closed.

 

Here is some crude code to illustrate the idea:

names default to here(1);

NewWindow("Test",
	BorderBox(top(20),bottom(20),left(20),right(20),
		VListBox(
			TextBox("Selected Parameter",<<setFontStyle("Bold")),
			HListBox(
				here:tb = TextEditBox("parameter name 1",<<enable(0),<<setWidth(130)),
				SpacerBox(size(6,0)),
				ButtonBox("select",
					NewWindow("Select",<<modal,
						<<onCLose(
							here:tb<<setText(cb<<getSelected)
						),
						BorderBox(top(20),bottom(20),left(20),right(20),
							cb = ComboBox({"parameter name 1","parameter name 2"})
						)
					),
					underlinestyle(1)
				)
			)
		)
	)
)

 

-Dave

View solution in original post

Highlighted
txnelson
Super User

Re: How to modify font size of text inside combo box?

This is a great idea.....the Button Box can actually just be an icon, and that icon can be a down arrow

Jim
Highlighted
James_Hark
Level I

Re: How to modify font size of text inside combo box?

Very creative, I like this approach a lot. Thanks!
Highlighted

Re: How to modify font size of text inside combo box?

If you are working with a window that is stretchable, you might consider making the Combo Box stretchable as well.  It will take min and max sizes, and while it prefers the full size of the text, it will shrink to a smaller size if forced to by a box like Splitter Box.  It does not offer truncation options, so you will only see the first part of the string.

 

New Window( "Combo",
	H Splitter Box(
		Size( 600, 300 ),
		gb=Graph Box(),
		combo = Combo Box(
			{"This is long combo option 1 that I would like to truncate",
			"This is long combo option 2 that I would like to truncate"},
			<<Set Min Size( 30, 1 ),
			<<Set Max Size( 3000, 1 ),
			<<Set Auto Stretching( 1, 0 )
		),
		<<Sizes({0.7,0.3})
	)
);
gb[FrameBox(1)] << Set Min Size(30,30) << Set Max Size(3000,1) << Set Auto Stretching(1,1);

Untitled.png

 

Article Labels