Robin Dunn wrote:
Frank Millman wrote:
> Hi all
>
> With MSW, pressing F4 expands a wx.Choice or wx.ComboBox so
that the
> user can use the up/down arrows to make a selection. I
cannot find a
> way to get similar behaviour with GTK2.
Hmm... I thought that there was a standard key to do it on
GTK too, but I can't seem to find it now.
Thanks, Robin. Sorry for the delay in replying. It took me a while to figure
out how the custom ComboCtrl works.
I have found that, if you use wx.Choice, the space bar expands the selection
in GTK2, which actually feels quite smooth. Of course that cannot work with
wx.ComboBox as it is editable, so a space is treated as replacing the
current string.
If you switch to using a custom ComboCtrl then you have more
control over it, and can force the drop-down to display.
Yes, this was a great suggestion, thanks.
I was looking for the equivalent of wx.Choice, so after experimenting, I
ended up with combining a wx.ListBox with a custom ComboCtrl. I have got it
working quite nicely, as you can see from the attached sample. It has the
following functionality -
1. clicking on the button or pressing the spacebar opens the listbox
2. clicking an item with the mouse selects the item and closes the listbox
3. using the up/down arrows changes the selection
4. pressing enter selects the item and closes the listbox
5. pressing escape closes the listbox without changing the selection
6. using the up/down arrows without opening the listbox scrolls through the
items in situ
This is almost the same functionality as wx.Choice itself, except -
MSW uses F4 instead of space to open the dropdown
GTK2 does not have number 6, which I find quite useful
I still have a few cosmetic problems -
1. I want to adjust the height of the listbox so that it is just big enough
to show the choices, but it is dependant on the height of the current font.
I was hoping that wx.ListBox would have a GetRowHeight method, but it does
not. What is the best way to determine the appropriate height?
2. With GTK2, when the listbox is open, the selected line is highlighted
with the brown, inactive, background instead of the usual blue one. Is there
a way to change this?
3. With GTK2, when the ComboCtrl loses focus, it leaves the text highlighted
with the brown, inactive, background. I want to clear the background
altogether. I had a similar problem with wx.TextCtrl, which I solved by
calling SetSelection(-1,-1) on LostFocus. I tried that with my new control,
but firstly, the lostfocus event seems to be triggered when the control
gains focus (!), and secondly, there is no SetSelection method. Is there a
way to solve this?
Thanks
Frank
fm55.py (4.51 KB)