If you want to save the user interface representation in a selection box based on, there is a (rather nasty) way you could do this. It is rather manual, and I would not recommend it at all, but it could achieve what you want:
For each option in the list, output "width" based on the characters in this text editor. This should be a vague representation of the proportional width of the font of the font (for example, ijtl = 1, aopg = 2, m = 2.5, roughly speaking, this kind of thing).
Everything that passes a certain value (evaluates this based on your available user interface space) gets a separation at the corresponding point (space or hyphen in a long word - you need to write an algorithm for this). Repeat until you have pieces to your desired size. You should get an array for each parameter (some will only be 1 if they are already short enough).
For each option with a matching array longer than 1, insert the option nodes immediately after the original containing each of the following text fragments. Give them a specific class (e.g. long-child ) and the same value as the original. You should probably also give some visual indicator that this is a continuation of the previous element.
Put an onchange event onchange to select which checks if the selected parameter has a long-child class. If so, he should look for the previous parameters to find the first that has the same value and does not have a long-child class. Instead, set selectedIndex to this parameter.
As I said, disgusting, but can achieve the desired effect. It may even be less code than Pawkaβs suggestion to ride on your own;)
source share