Listbox' selected row lost its highlight after vertical scroll

A selected row of a listbox will lost its highlight when the listbox is vertically scrolled enough so that the row not in display. When scrolled back to see the row again, the highlight is gone.
Has anyone experienced it?

Xojo version?
Can you create a sample?

Hello AlbertoD,

Thank you for your reply. Xojo 2022 r4.1 on MacOS. The app is a little complicated, but basically it has a DesktopListBox with four columns, and many rows that make the list box vertically scrollable.
A cell is clicked and put in edit mode by EditCellAt(). While the cell is in focus to be edited, the user scrolls the row away from the viewable area. When scrolling back to the editing row (cell), the highlight is gone. We want to keep the row highlighted.

I notice that if the cell is not in edit mode, that is no calling of EditCellAt(), the highlight stays.


Oh, ok, so this is what you see: (5)

and you want the listbox to stay in ‘Edit’ mode, right?

I don’t have experience with this, maybe someone can give you an idea.

I guess the cell has Focus when visible and when it scrolls out of the view the Focus is lost.

1 Like

Yes, that is correct, AlbertoD. :frowning:
If there is a way to catch the scrolling event then I could keep the row selected again when it is shown.

One way you could achieve this is using the PaintCellText event. If the row becomes visible, that event will be called. You’d store the edited row in a property (defaulting to -1 when there’s no editing) and, in the PaintCellText event:

if row=StoredRow then
StoredRow=-1 //Don't call twice
end if
1 Like

This sounds like a bug in DesktopListbox as I’m fairly sure the v1 API version doesn’t do this.

1 Like

I just tried this in an API 1 listbox and it behaves the same (incorrect) way. When the open edited cell is scrolled out of view and back, it is selected but not editable.

1 Like

Mine stays editable even when I left the application to the Finder or to another application and I come back to my ListBox (to continue to Edit that Cell)…

1 Like

I’m not sure of the logic of editing something you can’t even see? Finder does the same thing. If you press return on a file to start editing its name and then scroll that file out of view it stops being editable.

Perhaps this is more to do with a newer version of macOS that Xojo itself? I’m on Ventura

1 Like

That’s not the highlight, it’s the focus ring. You’d expect the focus to be elsewhere if the focuused item is no longer visible. In @AlbertoD 's example, when the row scrolls back into view, it is highlighted.


If you switch to another app leaving the focussed item visible, it will have focus again when you switch back to the first app.

Seems a non-issue to me.

1 Like

Not by default: you have to code it by yourself. The Cell, then the ListBox loose the focus when there is a window swap / application swap…
Please, check.

1 Like

I expected the highlight to be blue. What do you think?

1 Like

The blue outline is the focus ring, not the highlight.


I mean this:

I understand the selection is not blue because on the first clip the focus ring is on the cell, then the focus ring is lost when the cell is out-of-view, so the cell nor the listbox has the focus. On the image above there is no editcell so the listbox always keep the focus so the selected row is in blue and not in gray.

If I’m interacting with a listbox (using the scrollbar) and the focus is set on a cell and the cell lost the focus because is out of view, I expected the listbox to get the focus again and show the row in blue, but this is not the case. I guess it is designed this way.

1 Like

Apologies - I didn’t realise it was a cell being edited.

1 Like

You can turn off editing if it is not required?

1 Like

Thanks to all comments. I think there are two design philosophies:
A- If a row is selected and therefore highlighted (i.e., the whole row is in blue background), regardless of a field in that row being in edit mode or not (indicated by the presence or absence of the field’s focus ring), when the user scrolls it out of view and then back to view the row again, the highlight (and focus ring, or not) is expected to persist.

B- If a selected item (being a row or a field) is out of view, then it’s considered deselected.