In a former DB application (Paradox - possibly also Access?) there was an event “Mouse Double” which could be used to handle a mouse double-click on a control. Is there any means of emulating this on an LO Base form?
Hello,
You can use the mouse click event. At the beginning of the called routine, check if the click was double and exit if not:
If oEvt.ClickCount = 2 then
An example of this in a user created event for Calc can be found here → Calc BASIC | How to alter the previously opened dialog to be active ? And is there double click event for grid in dialog?
See DialogsOrig.ods
sample in my answer there.
Hmm … There is a ‘Mouse button pressed’ and a ‘Mouse button released’ event. I created a macro containing
if oEvent.ClickCount = 1 then
msgBox "Mouse clicked once"
else if oEvent.ClickCount = 2 then
msgBox "Mouse clicked twice"
Endif
But whichever event I attached it to, it responded immediately to the first click and did not count the second.
The question deals with handling a double click. Your comment has both a single and a double click. Don’t have a method for that. For double click:
Sub MouseClick(oEvent)
if oEvent.ClickCount = 2 then
msgBox "Mouse clicked twice"
Rem Actions here
EndIf
End sub
It appears when a double click is issued, both a single and double click event are issued. Here is an alternative. Ctrl
key with single click:
Sub MouseClick(oEvent)
Rem Single click with Ctrl key
if oEvent.ClickCount = 1 And oEvent.Modifiers = 2 then
msgBox "Mouse clicked once"
EndIf
if oEvent.ClickCount = 2 then
msgBox "Mouse clicked twice"
EndIf
End sub
There is also a right mouse button click:
oEvent.Buttons = 2
or on my system a middle button:
oEvent.Buttons = 4
and Shift key:
oEvent.Modifiers = 1
and many combinations.
Thank you. I have still not managed to detect a ClickCount of more than 1 (using the one-line macro msgBox oEvent.ClickCount & " click(s) detected"
attached to the ‘Mouse button pressed’ event), but Ctrl (or Cmd)-Click makes an acceptable alternative!
This works:
if oEvent.ClickCount = 2 then
msgBox oEvent.ClickCount & " click(s) detected"
EndIf
This does not work:
msgBox oEvent.ClickCount & " click(s) detected"
Indeed it does, and I can even use that to detect three clicks! But how bizarre: as soon as I add an ‘else’ clause, it stops working.
If oEvent.ClickCount = 2 then
msgBox oEvent.ClickCount & " click(s) detected"
else
msgBox oEvent.ClickCount & " click(s) detected"
Endif