The default behavior of FXListBox seems to be to grow and shrink in width depending on the length of the selected entry in the list. This is a problem when the list contains items of varying width, because if a short item is picked then the longer entries are obscured in the drop-down list. Is this deliberate, an oversight, or a bug? Its certainly not how I''d choose it to act. Is there some combination of options in the "new" method, or some layout manager setup, that can force the listbox to stay one (appropriately wide) width? Code to demonstrate the problem below. David -- David Peoples davidp@touringcyclist.com The Touring Cyclist http://www.touringcyclist.com 11816 St. Charles Rock Road, Bridgeton, MO 63044 tel: 314-739-4648 fax: 314-739-4972 ----------------------------------------------------- #!/usr/bin/env ruby # tested using FXRuby 1.2.5 and Ruby 1.8.2 (One-click installer # on Windows XP) require ''fox12'' include Fox application = FXApp.new("listboxtest", "FoxTest") main = FXMainWindow.new(application, "FXListBox test", nil, nil, DECOR_ALL, 0, 0, 400, 200) myListBox = FXListBox.new(main) myListBox.appendItem("a very long example") myListBox.appendItem("short") myListBox.appendItem("longer") myListBox.appendItem("even longer") myListBox.appendItem("shorter") myListBox.numVisible = myListBox.numItems application.create main.show(PLACEMENT_SCREEN) application.run
On Wednesday 23 March 2005 04:32 pm, David Peoples wrote:> The default behavior of FXListBox seems to be to grow and shrink in > width depending on the length of the selected entry in the list. This is > a problem when the list contains items of varying width, because if a > short item is picked then the longer entries are obscured in the > drop-down list.> Is this deliberate, an oversight, or a bug? Its certainly not how I''d > choose it to act. Is there some combination of options in the "new" > method, or some layout manager setup, that can force the listbox to stay > one (appropriately wide) width?Yes, looking through the code I see that there could indeed be a problem. What happens is that the getDefaultWidth() of the FXListBox reflects only the size of the currently selected text, and not the size of ALL the texts in the list. This is wrong, plain and simple! In FXComboBox I fixed this by setting HSCROLLING_OFF on the embedded FXList, if the combobox is static. Since FXListBox pretty much behaves like a static FXComboBox, this should probably be done inside FXListBox also. I would suggest, for now, hard-wire the size of the FXListBox to the desired width, with the LAYOUT_FIX_WIDTH flag. Then the parent widget will ignore the value of getDefaultWidth() and just give it the right size. Thanks for the bug report, Jeroen -- +----------------------------------------------------------------------------+ | Copyright (C) 19:30 03/23/2005 Jeroen van der Zijp. All Rights Reserved. | +----------------------------------------------------------------------------+
Jeroen van der Zijp wrote:> On Wednesday 23 March 2005 04:32 pm, David Peoples wrote: > >>The default behavior of FXListBox seems to be to grow and shrink in >>width depending on the length of the selected entry in the list. This is >>a problem when the list contains items of varying width, because if a >>short item is picked then the longer entries are obscured in the >>drop-down list....> I would suggest, for now, hard-wire the size of the FXListBox to the desired > width, with the LAYOUT_FIX_WIDTH flag. Then the parent widget will ignore > the value of getDefaultWidth() and just give it the right size. > > > Thanks for the bug report, > > > Jeroen > >OK, that work-around works for me. Thanks. David -- David Peoples davidp@touringcyclist.com http://www.touringcyclist.com The Touring Cyclist, 11816 St. Charles Rock Road, Bridgeton MO 63044 tel: 314-739-4648 fax: 314-739-4972