CellClick on release mouse

On macOS the Listbox CellClick event is triggered when releasing the mouse (equivalent of MouseUp) which is imo correct behaviour.
But on Windows the CellClick event is already triggered when clicking down the mouse (equivalent of MouseDown).

Two questions:

  • Why is this the case?
  • Is there a workaround for this?

For as long as I know, it was a well known fact that Mac and Windows handled double clicks differently: Mac would trigger double clicks on mouse up and Windows on mouse down (earlier). Those are “little” differences that make me remembering why I prefer Macs :wink:

I wouldn’t try to assume your case is different.

Actually, on Windows every time you click on a cell you get a MouseDown. If the event handler returns True then you get a MouseUp but no CellClick or DoubleClick (DoublePressed on API2). If the MouseDown returns False you don’t get a MouseUp but you do get the CellClick.

If the MouseDown returns False AND the second mouse release returns within the necessary area and timing you will also get the DoubleClick. This can be seen if you do a quick MouseClick-Release-MouseClick and not doing the second release of the mouse button for a few seconds. On Windows (at least) the DoubleClick won’t fire.

Answer (Xojo guys): Bring back mouse and key events, please.

Basically it is what I said … .CellClick is always triggered in mouse down (which is not correct behaviour imo).

1: was there a CellClik in Xojo (Real Studio or REALbasic) ?

2: MouseDown with MouseUp lets you “regret” to click there (if you release - MouseUp - out of the Control aera). CellClick will not.

3: Yes, Microsoft knows about CellClik (DataGridView.CellClick Événement (System.Windows.Forms))

List of DesktopListBox available Events:

For the new API2 it is CellPressed. But the issue is the same.

With the events that exist (cellpressed, mousedown, mouseup, mouse enter, mouseexit) you can implement any behaviour you wish.

In my case, my buttons when clicked (pressed) become darker. However they don’t do any action until you release the mouse. Or if as @Emile_Schwarz says you “regret” it, you can move the mouse outside the button and it becomes light again. Release the mouse at this point and nothing happens.

Well, how can I get an event triggered, only on mouse up after I click on a cell?

My buttons are instances of a DesktopContainer.

In Mousedown:

if  (IsContextualClick=True)  then Return False
mouseisDown = True
me.Refresh ()
Return True

In MouseExit:

resetState ()

In MouseUp:

if  (X<0 or X>me.Width or Y<0 or Y>me.Height)  Then Return
if  (mouseisDown=True)  Then DoButtonWork ()
resetState ()

resetState() is a container method:

if  (me.mouseisDown=False)  then Return
me.mouseisDown = False
me.Refresh ()

mouseisDown is a container property. The paint event uses it to decide what colour to paint the button background.

Yes obviously, but that does not return the ROW value (which it does in CellClicked event and which I need).

And for what worth: Using .rowFromXY(x,y) in the mouse down event is not reliable.

So in CellPressed you store row and column and Return False.

I think I tried this in the past and didn’t work. But will try again.

So, you need CellMouseClick…:grinning: