ListBox : click on a column separator fires a MouseDown

So, how to avoid that a “MouseDown” event is fired when we have simply clicked on a column separator?

Or : how to recognize that this click is on a separator, and does not have to be managed?

Xojo 2020r21

Uncheck Allow Resize Column.

This is not a default value; a.k.a. you set it, but you do not told us.

What other difference(s) properties your ListBox have ?

https://documentation.xojo.com/api/deprecated/listbox.html#listbox-allowresizablecolumns

The LR says:

Notes

When the pointer is over a divider, it changes to an East-West Splitter pointer to indicate that the user can drag the divider

You do not saw the cursor change ?

I have to keep “Allow Resize Column”, something to do when the user clicks on the header

So, use x,y to determine where the click have been done.

I tried:
System.DebugLog "ColumnFromXY:: " + Str(Me.ColumnFromXY(x,y))
System.DebugLog "RowFromXY:: " + Str(Me.RowFromXY(x,y))

and get a Cell and Row anywhere I click. So the trick have to be using directly x,y.

Column(0).Width+1 is probably a click in the vertical separator, but I was not able to click and not select a Row, so I am not sure of what you think.

In other words, I do not know when I click in the vertical separator instead of inside a Cell.

A click in the Header returns -1. And there the click IS in the vertical separator.

Thank you Emile, of course, I can calculate the positions and manage according to, but I would have liked a more “xojo” solution …
No other idea?

No, but one question:

are-you able to click in a column separator outside of the ListBox Header ?

I was not: each time I tried, the Row as selected.

Can you read the System.Cursors environment variable to do something like:

If Me.MouseCursor <> System.Cursors.ArrowEastWest Then
  ...
End If

Sascha, good idea, but don’t works, even with App. MouseCursor…
Emile, for me a separator is a separate object, and when you use it the program shouldn’t continue on MouseDown

Then i’d do what Emile suggested. (And write a Feature Request in the Xojo Feedback System, maybe?) :slight_smile:

This is good when the MouseCursor is in the ListBox Heading area, not in the Rows, never.

OK: I stop responding because I am not able to replicate the problem.

Xojo 2020r2.1
High Sierra

This in your mousedown handler:

if  (y<me.HeaderHeight)  Then Return False              // In the header, ignore here

.
and you’re using the HeaderPressed event too, aren’t you?

I can’t use HeaderPressed because I need to handle a right click, and neither IsContextualClick nor ConstructContextualMenu is fired in HeaderPressed
So I had to manage the click in a separator, here the code at the beginning of MouseDown :

const kecardacol = 2
const kecargocol = 4
var wi, wposgo, wposda as integer
if y <= me.HeaderHeight then
    for wi = 0 to me.ColumnCount - 1
      if wi > 0 then wposgo = wposgo + me.ColumnAt(wi-1).WidthActual
      if wi < me.ColumnCount then wposda = wposda + me.ColumnAt(wi).WidthActual
      if (x >= wposgo and x <= wposgo + kecargocol) or (x >= wposda - kecardacol and x <= wposda) then
        return false
      end
    next
end

And it works as I want, I can handle Click and ContextualClick on the Header after this code, and I can resize the columns :slight_smile:

Thanks for your advices !