Double click event

Hello everybody
I need to get the column and the row (Column, Row) of a Calc sheet by double clicking with the mouse.

I have found many examples on this site, but they are too advanced for me.
I tried:

REM  *****  BASIC  *****
sub sub_Mouse
	oListener = CreateUnoListener("XMouseHandler_", "com.sun.star.awt.XMouseListener")
end sub

Sub XMouseHandler_mousePressed(oEvent)
    if oEvent.ClickCount = 2 then 
       	msgBox "Mouse clicked twice"
		Rem Actions here
    EndIf
End Sub

it does not work.
i just don’t know how to create this event.
Please help me

You’re using very old code samples, it’s a little easier today.

All the information you need about the cell that you double-clicked you will get from the oEvent parameter:

Sub onDblClick(oEvent As Variant)
	Print "DblClick on cell " + oEvent.AbsoluteName + _
		" (row " + oEvent.CellAddress.Row + _
		" and column " + oEvent.CellAddress.Column + ")"
End Sub

And it’s even easier to assign an event listener:

3 Likes

Perfect!
Thank you

Small addendum. If you describe not a procedure, but a function (returns Boolean), then by assigning return value True, you can cancel the default double-click processing.

1 Like