Listbox Deselect

I you have a listbox with some rows, users may click on a row; and the row is selected. If users click on the white space below the rows, nothing is selected. One can detect this and do whatever is necessary.

The problem in Windows is that the previously selected row retains a gray outline. My tester felt this would be confusing.

Searching the Forum I found a suggestion to simply reload the listbox. This seemed a bit like overkill.

Here’s something I tried that appears to work: i appended a blank row, selected it, and then removed it. This is in the Change event if me.listindex = -1

row = me.lastindex
me.selected(row) = true

Hope this helps.


lb.Invalidate doesn’t do it?

The grey dotted outline is actually standard windows behaviour IF a key has been pressed while focus is in that window, its part of the keyboard assisted navigation system, it shows you where your keyboard navigation will move from when you return to the control. Try it on the printer select window of notepad, if you pick a printer, press tab (to activate the dots) then click the white space next to the printers the grey dotted outline shows up on your old selection. The bug (<>) in Xojo is that its showing all the time even if a key isn’t pressed which isn’t standard windows behaviour. I agree, it looks bad being there from the start however I wouldn’t program around it as people who use keyboard or accessibility controls to navigate your window will have issues with the loss of focus.

Turn off UseFocusRing for that listbox either in the Inspector or in code.