[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mouse.Button , ensure correct right button value
[Thread Prev] | [Thread Next]
- Subject: Re: Mouse.Button , ensure correct right button value
- From: Bruce Steers <bsteers4@xxxxxxxxx>
- Date: Tue, 2 Apr 2024 15:14:38 +0100
- To: user@xxxxxxxxxxxxxxxxxxxxxx
On Tue, 2 Apr 2024 at 13:55, Bruce Steers <bsteers4@xxxxxxxxx> wrote:
>
>
> 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
>
*Aah I just discovered this is probably just a QT/GTK thing. !*
Seems Right and Middle button value is inverted with QT5 and GTK3
With QT5 Mouse.Button = 2 for Right 3 for Middle
With GTK3 Mouse.Button = 3 for Right 2 for Middle
So my code could possibly just be like this (to ensure is correct on both
toolkits)
(no idea what wayland uses)
Private $iRight As Integer = 2
Private $iMiddle As Integer = 3
Public Sub Form_Open()
If Component.IsLoaded("gb.gtk") Or If Component.IsLoaded("gb.gtk3") Then
$iRight = 3
$iMiddle = 2
Endif
End
Public Sub Form_MouseDown()
If Mouse.Button = 1 Then
Print "Click was Left"
Else If Mouse.Button = $iRight Then
Print "Click was Right"
Else If Mouse.Button = $iMiddle Then
Print "Click was Middle"
Endif
End
Respects all
BruceS
| Mouse.Button , ensure correct right button value | Bruce Steers <bsteers4@xxxxxxxxx> |
| Re: Mouse.Button , ensure correct right button value | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Mouse.Button , ensure correct right button value | Bruce Steers <bsteers4@xxxxxxxxx> |
| Re: Mouse.Button , ensure correct right button value | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Mouse.Button , ensure correct right button value | Bruce Steers <bsteers4@xxxxxxxxx> |