Problem with menu in gridview

Post your Gambas programming questions here.
User avatar
thatbruce
Posts: 170
Joined: Saturday 4th September 2021 11:29pm

Re: Problem with menu in gridview

Post by thatbruce »

Ah Grasshopper! Again you have failed to respect history. Olde tyme myce had only two buttons (there is some pre-history regarding a "one button mouse" but that can be disregarded) hence the numbering.
:| :twisted: :D
b
Have you ever noticed that software is never advertised using the adjective "spreadable".
User avatar
BruceSteers
Posts: 1585
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Problem with menu in gridview

Post by BruceSteers »

Is it the same for Mouse.State?

Dang it, now i need a 2 button mouse to test with.

And I gotta think of a workaround now :-\

Best i can think of is this,,

Note the Mouse.Button value on MouseDown and then use the _Menu() event to set it.
But the _Menu event needs to fire before it's known.


Private $iRightButton as Integer = -1
Private $iCurrentButton as Integer

Public Sub Form_MouseDown()

  $iCurrentButton = Mouse.Button  

End

Public Sub Form_Menu()

  If $iRightButton = -1 Then
    $iRightButton = $iCurrentButton
  Endif

End



Then i know if $iRightButton <> -1 then the Right (menu) button is known.
Darn i wish things were simpler
If at first you don't succeed , try doing something differently.
BruceS
bill-lancaster
Posts: 195
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: Problem with menu in gridview

Post by bill-lancaster »

My centre button returns mouse.button=3 and Right click gives Mouse.Right=True.
User avatar
BruceSteers
Posts: 1585
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Problem with menu in gridview

Post by BruceSteers »

bill-lancaster wrote: Tuesday 2nd April 2024 1:27pm My centre button returns mouse.button=3 and Right click gives Mouse.Right=True.
Be careful using Mouse.Left and Mouse.Right though Bill as they are more like button "down" registers than button "click".

Ie , if you press left button while right button is also held down then Mouse.Right will be true with the left click. (if that makes sense)


Aah I just discovered this could just be 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 the 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




PS. apologies Bill for slightly hijacking this thread with my outrageous need for accuracy ;)

But i hope you have got some good stuff out of it (i know I did) :)
If at first you don't succeed , try doing something differently.
BruceS
bill-lancaster
Posts: 195
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: Problem with menu in gridview

Post by bill-lancaster »

Not a problem Bruce.
Peculiar behavior of gridview and mouse fully explored!
Bill
Post Reply