Being careful with the mousedown event in a ListBox

I was happy with the mousedown event in the listbox, as it allowed me to take some actions if the user clicks after the last real row in the listbox. But personally, I find the doc for this event to be a bit incomplete regarding whether to return true or false from the event handler, so there was a place where I returned true.

What I then discovered is that this:

  1. Prevents the headerPressed event from firing

  2. Prevents the resizing of columns in the listbox even if the listbox is set to have resizeable columns.

Taking care in the mousedown event to compute whether the mousedown was in the header (the x,y coords include the header) and then returning false restored the expected behaviour.

When an event has a Boolean return parameter, it is most often used to suppress standard behavior. The default Boolean value is false, so you usually don’t have to return anything to preserve the system default.

MouseDown uses its return parameter to decide about further processing of mousebutton events, which in a simple control is only MouseUp, but a listbox is a complex compound with more connected events in the pipeline. Which admittedly is not clear from the documentation as MouseDown links to a general RectControl explanation.

EDIT: Could you write a feedback feature request to have the info about HeaderPressed and column resizing being suppressed in a listbox added to the docs?

So a bit similar to the stopPropagation and preventDefault method in javascript, then, by the sound of it.

Yes, and a bit unfortunate that the doc is organised this way. The general explanation you refer to talks about the Action event being suppressed, I suppose the HeaderPressed event counts as an action event in this context.

Yes. Thanks for the reply, BTW, which has helped clarify matters.

Doc update requested: <https://xojo.com/issue/53953>