KeyPress event double fires after using MouseWheel

Post

Posted
Rating:
#1 (In Topic #1014)
Regular
JumpyVB is in the usergroup ‘Regular’
The problem can be reproduced like this:

1) Create new "Graphical application"

2) Add a Button to FMain (we shall call it Button1, no events needed)

3) Paste this code to FMain.class:

Code (gambas)

  1. Public Sub Form_KeyPress()
  2.     i = i + 1
  3.     Me.Text = CStr(i)
  4.  
  5. Public Sub Form_MouseWheel()
  6.   ' Empty on purpose

4) Run

5) Try pressing right arrow on the keyboard to increment i by 1

6) Turn the mouse wheel once.

7) Try pressing right arrow on the keyboard and it increments i twice !?!?

8) Click Button1.

9) Try pressing right arrow on the keyboard again and it will increment i by 1

The weird behaviour has something to do with .HasFocus

Am I missing something here or is this a bug that should be reported to Benoit Minisini?

PS: I am using Gambas 3.18.90 on Linux Mint 21.1 Cinnamon 5.6.8
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’
With this your line:

JumpyVB said

Code (gambas)

I get the increment of the global variable, even if I press the other keys.
So, I propose to use this other line of code:

Code (gambas)

  1. If Key.Code = Key["Right"] Then ....

JumpyVB said

7) Try pressing right arrow on the keyboard and it increments i twice !?!?
It doesn't happen to me. :|

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
JumpyVB is in the usergroup ‘Regular’

vuott said

It doesn't happen to me. :|

Whats your gambas and os version?
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Guru
cogier is in the usergroup ‘Guru’
I'm also using Mint 21.1 and the problem you report also happens to me, but I have discovered that this only happens with gb.gui. If you change from GTK to QT using gb.gui.qt instead, the problem goes away. Whether this is a bug in Gambas or in GTK, I leave to others to work out.
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
JumpyVB is in the usergroup ‘Regular’

cogier said

I'm also using Mint 21.1 and the problem you report also happens to me, but I have discovered that this only happens with gb.gui. If you change from GTK to QT using gb.gui.qt instead, the problem goes away. Whether this is a bug in Gambas or in GTK, I leave to others to work out.

Thank you for confirming.
Online now: No Back to the top
1 guest and 0 members have just viewed this.