I have a dropdown component whose width is restricted in size. However the options for this dropdown are strings that are longer than the width of the drop. Is there a way to make the dropdown list wider? I just need to see the options when selecting one. i know it wont look right once i select it but that is ok.
Thanks for the quick reply. Iāll play around with this when i get a few free moments. I am using 7.9. I guessing that I should put this script on something link the mouse pressed event script?
Thanks for this snippet! Seems to do exactly what I need. However, when attempting to use it in my scenario (with it on a mouse pressed event for testing) I get
AttributeError: type object 'javax.swing.plaf.basic.BasicComboPopup' has no attribute 'computePopupBounds'
I assume this is a configuration issue where my script canāt access the protected method. Are there any workarounds for this?
I ran into the same issue that you did, but was able to resolve it by tweaking the code slightly. I was unable to achieve a āsmartā sizing of the popup (i.e. - based on the length of the longest item in the list), but for my purposes, all I really wanted was a way to āforceā the popup list to be a certain width, so maybe this very rough snippet will help you.
Then, in the visionWindowOpened event handler for my window, I added these lines:
win = system.gui.getParentWindow(event)
#Get the dropdown component
comp = win.getComponentForPath('Root Container.MetaContainer.MyDropDown')
#Call the 'customWidth' function once on window open
#This example uses a 'static' width of 400, but it could also be
#some value calculated at runtime, however you'd have to call this function
#again if you want to change it
Utils.setCustomWidthComboPopup(comp, 400)
Some limitations of this quick and dirty implementation:
As I mentioned, it doesnāt do any fancy āauto-sizingā of the dropdown popup
The dropdown popup is still left-aligned with the dropdown itself (i.e. - it grows to the right). Iām sure if someone wanted it to be right-aligned with the dropdown box, that could be achieved, but I didnāt put in the effort
Iām sure someone with more time/skills could improve upon this.