Ask Your Question
0

Can Base handle a mouse double-click?

asked 2020-07-23 10:00:02 +0200

Philip K gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-07-23 18:57:31 +0200

Ratslinger gravatar image

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.

edit flag offensive delete link more

Comments

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.

Philip K gravatar imagePhilip K ( 2020-07-23 22:37:03 +0200 )edit

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
Ratslinger gravatar imageRatslinger ( 2020-07-23 23:11:02 +0200 )edit

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.

Ratslinger gravatar imageRatslinger ( 2020-07-24 00:42:38 +0200 )edit

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!

Philip K gravatar imagePhilip K ( 2020-07-24 10:22:08 +0200 )edit

This works:

if oEvent.ClickCount = 2 then 
    msgBox oEvent.ClickCount & " click(s) detected"
EndIf

This does not work:

    msgBox oEvent.ClickCount & " click(s) detected"
Ratslinger gravatar imageRatslinger ( 2020-07-24 18:46:04 +0200 )edit

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
Philip K gravatar imagePhilip K ( 2020-07-24 19:09:44 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-07-23 10:00:02 +0200

Seen: 29 times

Last updated: Jul 23