Ticket #3224 (confirmed defect)

Opened 7 years ago

Last modified 7 months ago

wxListBox's EnsureVisible not implemented in wxMSW

Reported by: jejackson Owned by:
Priority: low Milestone:
Component: wxMSW Version:
Keywords: wxListBox simple Cc: jejackson, leio
Blocked By: Patch: no
Blocking:

Description

I've tried using wxListBox's EnsureVisible to make sure that top element
of a list box is the displayed item.

However, if there is a selection that would be out-of-view, it always
scrolls to that one instead of what EnsureVisible is set to.

Code snippet: (wxPython)

listBox.SetSelection(10)
listBox.EnsureVisible(0)

always shows item 10, and not item 0.

It appears from looking at the sources that this was never implemented.

Attachments

3224.patch download (1.5 KB) - added by oneeyeman 7 months ago.
Implementation patch

Change History

Changed 7 years ago by leio

From bug #836309:

Razvan Cojocaru:

EnsureVisible() doesn't scroll with the correct ammount
on wxGTK 2.5.1 and wxMac 2.5.1, so the wanted item is
not shown. I don't know if the problem exists on other
wxWindows flavours, but I've een it for myself on wxGTK
2.5.1 and it's been reported that it happens with wxMac
CVS HEAD.

Changed 5 years ago by wojdyr

  • keywords wxListBox added
  • status changed from new to closed
  • resolution set to invalid

wxListBox has EnsureVisible() in the base class, but it's not documented and it's not implemented in wxMSW.

Changed 5 years ago by vadz

  • status changed from closed to reopened
  • resolution deleted

I think we should document EnsureVisible() and support it. OTOH I don't know if the problem is still present in 2.8 or svn trunk, could someone please test this?

Changed 5 years ago by vadz

  • priority changed from normal to low
  • status changed from reopened to infoneeded

Changed 5 years ago by wojdyr

  • status changed from infoneeded to accepted

afaict it's not implemented on wxMSW and never was implemented. There is nothing to test, this function is just empty.

Changed 9 months ago by oneeyeman

The documentation for wxListBox::EnsureVisible() was added and it mentions that the function implemented only on GTK and Mac.

Probably worth changing the subject so that someone will implement that.

Changed 9 months ago by vadz

  • keywords simple added
  • status changed from accepted to new
  • component changed from GUI-generic to wxMSW
  • summary changed from wxListBox's EnsureVisible not implemented to wxListBox's EnsureVisible not implemented in wxMSW

Considering that wxMSW does implement SetFirstItem(), it shouldn't be difficult to implement this one.

Changed 9 months ago by vadz

  • status changed from new to confirmed

Changed 7 months ago by oneeyeman

Implementation patch

Changed 7 months ago by oneeyeman

  • patch set

Attached please find a patch that implements EnsureVisible for the listbox in wxMSW.
It also corrects the documentation.

Changed 7 months ago by vadz

  • patch unset

Sorry, this is not the right implementation. If EnsureVisible() were the same as SetFirstItem(), what would be the point of having it?

EnsureVisible() is supposed to scroll just enough to make the item visible and, in particular, not scroll at all if it's already visible.

Note: See TracTickets for help on using tickets.