ListBox - making only checkboxes clickable

Hi, guys,

I have a ListBox with checkboxes. The ListBox is populated programmatically (via code).

I want to make only the checkboxes of the list clickable (I do not want the user to be able to select a row in the list).

Is this possible?

Thank you,

Val

10 minutes to not find how to set the Row in a API2 ListBox…

Was Me.ListIndex = -1 in API1, but… was changed to be more intuitive.

Can I get a more intuitive brain exchange, please ?

Emile,

I have no idea what you just said.

Val

What Xojo version are-you using ?

2019 r3 - Mac

Same here (for tests).

The idea was to Reject the click in MouseDown in setting ListIndex to -1.

I wanted to test before sharing, but I failed…

The selection indicator is just a drawing. You can override the drawing of the selected row with CellBackgroundPaint. I’ve done just this in my own apps. Fill a rect the size of the cell that is the color of the background of the control and return true. This will override the selection drawing.

Alternatively, you could change the selection by to -1 whenever it changes. This approach may come with unexpected behavior.

Emile, you can still use the classic API (Listbox.ListIndex) in 2019r3 it only does not show in auto complete.

[quote=471146:@Emile Schwarz]10 minutes to not find how to set the Row in a API2 ListBox…

Was Me.ListIndex = -1 in API1, but… was changed to be more intuitive.

Can I get a more intuitive brain exchange, please ?[/quote]

Maybe SelectedRowIndex?

Intuitive brains are deprecated.

and the ESP module is still not released… :wink:

Big thanks to everyone for the suggestions.

It appears that implementing a possible solution is more of a trouble than a benefit for the application.

Thank you again,

Val

in the Change Event this row will undone a selection

If Listbox1.SelectedRowIndex  >-1 Then Listbox1.SelectedRowIndex  = Listbox1.NoSelection

For mouse UI I would just intercept mouse down in all cells in the row and flip the checkbox state for that row and return true in the event.

That way the user can click anywhere in the row and change the checkbox state, but no row can be selected my mouse

For keyboard navigation I would use Tim’s suggestion to paint the background AND text so as not to the selection. Also in the key down event check for space (spacebar) and if pressed toggle the checkbox state and return true

-Karen