cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
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
David_Burnham
Super User (Alumni)

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
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
David_Burnham
Super User (Alumni)

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
David_Burnham
Super User (Alumni)

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
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
James_Hark
Level I

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

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

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