I have been working on a widget like the Google Chrome URL search bar, which not only lists items in a drop-down, but allows searching that list and having the results displayed in real-time in the drop-down list.
Problems:
When I have word-wrap turned on for the text (long strings will wrap instead of being cut-off), the scroll-bar changes size as I scroll down the list. It seems like lines out-of-view are using a single line-height for each item, but since the items can be multi-line, this is failing. I am not storing the multi-line version, rather I’m recalculating on pop-up in case the drop-down list changes width (i.e. frame was resized and drop-down got wider).
Scrolling with the mouse-wheel doesn’t work while the focus is in the TextCtrl… I think this might be an easy fix.
Anyway, basically check the difference between the top drop-down (wordWrap = False) and the lower drop-down (wordWrap=True)
You can’t see it very easily as this demo only changes by 1 pixel… so I modified that demo slightly to show the effect. See attached and scroll the left-hand list down, you’ll see the scrollbar get smaller the further down the list you scroll.
On Tuesday, September 2, 2014 12:21:21 PM UTC-7, Nathan McCorkle wrote:
I have been working on a widget like the Google Chrome URL search bar, which not only lists items in a drop-down, but allows searching that list and having the results displayed in real-time in the drop-down list.
Problems:
When I have word-wrap turned on for the text (long strings will wrap instead of being cut-off), the scroll-bar changes size as I scroll down the list. It seems like lines out-of-view are using a single line-height for each item, but since the items can be multi-line, this is failing. I am not storing the multi-line version, rather I’m recalculating on pop-up in case the drop-down list changes width (i.e. frame was resized and drop-down got wider).
Scrolling with the mouse-wheel doesn’t work while the focus is in the TextCtrl… I think this might be an easy fix.
Anyway, basically check the difference between the top drop-down (wordWrap = False) and the lower drop-down (wordWrap=True)
Got the mousewheel to scroll, and added a timer to disable the mousehover selection for 500 milliseconds after scrolling with mousewheel.
Still haven’t figured out the scrollbar thing, though I did try calling SetScrollbar(wx.VERTICAL, 0, 16, 50) on the VListBox and saw the scrollbar change (then changed back as soon as I scrolled)…
I don’t see any examples of people using SetScrollbar with VListBox online… so I’m not sure when I should be determining the range and size though (i.e. which event should I do this in?).
Got the mousewheel to scroll, and added a timer to disable the
mousehover selection for 500 milliseconds after scrolling with mousewheel.
Still haven't figured out the scrollbar thing, though I did try calling
SetScrollbar(wx.VERTICAL,0,16,50) on the VListBox and saw the scrollbar
change (then changed back as soon as I scrolled)...
I don't see any examples of people using SetScrollbar with VListBox
online... so I'm not sure when I should be determining the range and
size though (i.e. which event should I do this in?).
You shouldn't need to, the VScrolledWindow and derived classes take care of the scrollbar themselves, and so they reset it to what they think it should be after you've set it to what you think it should be.
I think your problem stems from the fact that you don't word-wrap the lines until they are being shown, so the first pass that the VListBox takes through the data is measuring everything at 1 line high. It's not able to get the accurate measurements until it fetches the strings to display, which is done on-demand when they come into view. If you were able to provide the wrapped measurements from the very beginning then I bet it would work the way you want it to. Otherwise having the scrollbar adjust as items are scrolled into view isn't too terrible IMO.