I need to change Font properties (e.g. size, font) for the items (all) inside a dropbox in Vision. The "Font" property is not changing the items, indeed only the selected value/label.
I already tried with html formatting (e.g. putting in the text in the dataset ) but it does not work (it is simply ignored).
How can I do?
I'm not seeing this.
Do you have any other formatting going on, like through the style customizer?
1 Like
No style customizer entry is present.
I need to change the font/size of the items in the dropdown list..
There is no need for this. The font
property is automatically applied to the dropdown item text. Try deleting the component and replacing it to make sure that instance hasn't been corrupted in some way. Just out of curiosity, what version of Ignition is this?
1 Like
I re-created, same behaviour. I understood, the problem is the "Dropdown Display mode" property: with "List" it works, with "Table" (as I need) does not.
Similar issue in a PowerTable: if i configure the options as dropdown, it works but with a font different in respect of Power table one and I'm not able to change.I think for this one (PT) Java swing is the road...indeed not so convenient (for me at least).
Version is 8.1.39
That makes sense. In that case, there are at least two options: you can use my Searchable Dropdown template from the exchange which has a table mode and a built in option to change the font size of the dropdown table, or you can hack the regular dropdown's table and change its font with scripting.
With the Ignition Exchange: Searchable Dropdown option, set the fontFixedSizeEnabled property to true, and set the fontFixedSize property to whatever the desired dropdown font size is. This will override the default font scaling and use the only the specified font size:
Result:
This option also has properties for customizing the various foreground and background colors of the dropdown independently of each other.
To hack the internal table of a regular dropdown component, the table can be obtained from the popup and manipulated directly. Here is a script I adapted from something I previously developed for programmatically setting the column widths of a dropdown:
# Run only once at initialization if the display mode is set to table [0 = list, 1 = table]
# Will not run in the designer unless preview mode is already running before the window is opened
if event.propertyName == 'componentRunning' and event.source.mode:
# Recursively search the popup's subcomponents, locate the table and return it
def getTable(popup):
for component in popup.components:
if 'JTable' in component.__class__.__name__:
return component
elif getTable(component):
return getTable(component)
# Retrieve the popup from the ui, locate the internal table and set its font to the dropdown's font
dropdown = event.source
ui = dropdown.UI
for child in range(ui.getAccessibleChildrenCount(dropdown)):
popup = ui.getAccessibleChild(dropdown, child)
if 'TableComboBoxPopup' in popup.__class__.__name__:
table = getTable(popup)
table.font = dropdown.font
break
Result:
2 Likes
Thx. Very clear and useful.
Last thing: any way to setup the font of a dropdown inside a cell of a Power Table?
Do this in the configureEditor extension function. Just add a font condition to the return statement that creates the dropdown.
Example:
if colName == 'Test Column':
return {'font': self.font, 'options': [('Test Option 1', 'Test Option 1'), ('Test Option 2', 'Test Option 2'), ('Test Option 3', 'Test Option 3')]}
Result:
1 Like
It perfectly works. It was also clearly written in the configureEditor description among the returned dict objects. I missed that! sorry ...