[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mouse.Button , ensure correct right button value


On Tue, 2 Apr 2024 at 13:35, Gianluigi <gradobag@xxxxxxxxxxx> wrote:

> Il 02/04/24 14:20, Bruce Steers ha scritto:
> > Private $iRight As Integer = -1
> >
> > Public Sub Form_MouseDown()
> >
> >    If $iRight = -1 Then
> >    Select Mouse.Button
> >      Case 2
> >        If Mouse.Right And If Not Mouse.Middle Then $iRight = 2 Else
> > $iRight = 3
> >      Case 3
> >        If Mouse.Right And If Not Mouse.Middle Then $iRight = 3
> >    End Select
> >    Endif
> >
> > End
> >
> > Then once $iRight is not -1 i know exactly what Mouse.Button is right
> click
>
> maybe you will find safer:
>
> Public Sub Form_MouseDown()
>
>    If Mouse.Left And If Mouse.Right Then Return
>    If Mouse.Left Then
>      Print "You pressed on the left button!"
>      Return
>    Else If Mouse.Right Then
>      Print "You pressed on the right button!"
>      Return
>    Endif
>
> End
>
> Regards
> Gianluigi

Not really, I think it's less safe than my code.  (c'mon Gian, you gotta
know if i'm asking here the answer probably is not quite that simple) :)
If multiple buttons are pressed then the click detection can be missed.

With your code if right mouse button is clicked while holding left down it
will fail to detect the right click.

I think with my code if mouse right and mouse middle are pressed together
it can also miss. but it only misses determining right button value. once
right button value is known i can use it to confidently detect what was
clicked with "If Mouse.Button = $iRightValue"
Using Mouse.Button is the better option in this situation than Mouse.State
or Mouse.Left/Mouse.Right etc
but determining if Right is Mouse.Button 2 or 3 is the issue.

A Property like Mouse.RightButtonValue could be useful

Respects
BruceS

Follow-Ups:
Re: Mouse.Button , ensure correct right button valueBruce Steers <bsteers4@xxxxxxxxx>
References:
Mouse.Button , ensure correct right button valueBruce Steers <bsteers4@xxxxxxxxx>
Re: Mouse.Button , ensure correct right button valueGianluigi <gradobag@xxxxxxxxxxx>
Re: Mouse.Button , ensure correct right button valueBruce Steers <bsteers4@xxxxxxxxx>
Re: Mouse.Button , ensure correct right button valueGianluigi <gradobag@xxxxxxxxxxx>