[Gambas-user] There are errors in the class "Key", and in the events KeyPress / KeyRelease?

Benoît Minisini gambas at ...1...
Tue Apr 13 18:31:18 CEST 2010


> Using Gambas 2.20, Ubuntu 9.10 with KDE 4.3.5 and GTK+ libraries
> 
> Key.Code is not returned? Key.Text is lost? KeyRelease is not raised?
> 
> Put a TextBox in a Form, then write the code to catch the pressed key.
> Run it and press a number o letter key.
> 
> PUBLIC SUB TextBox1_KeyPress()
>   PRINT Key.Code
>   PRINT Key.Text
> END
> 
> PUBLIC SUB TextBox1_KeyRelease()
>   PRINT Key.Code
>   PRINT Key.Text
> END
> 
> Result Tests (gb.qt)
> ----------------------------
> 
> pressed the '5' key
> 
> KeyPress: Key.Code = 53, Key.Text = "5"
> 
> KeyRelease: Key.Code = 53, Key.Text = ""

Key.Text is not guaranteed to be set during a KeyRelease.

> 
> Randomly KeyRelease wasn't raised.

Please specify, I didn't notice any problem about that.

> 
> 
> Result Test (gb.qt)

I think you meant gb.gtk instead.

> --------------------------
> 
> pressed the '5' key
> 
> KeyPress: Key.Code = 0, Key.Text = "5"

Yep, this is a bug I fixed in revision #2891. I'm almost sure that it worked 
before, so maybe a recent change in GTK+ made my code fail.

> 
> KeyRelease: Key.Code = 53, Key.Text = "5"
> 
> Randomly KeyRelease wasn't raised.

Please specify, I didn't notice any problem about that.

> 
> 
> Issues in two real proyects (I'm trying to isolate the problem):
> ---------------------------------------
> 
> KeyPress never is raised when gb.gtk is used.

No, it is raised, but Key.Code was zero.

> 
> KeyPress sometimes is not raised when gb.qt is used.

As I said before, I didn't notice that. So if you can tell me how to reproduce 
it, it would be a great thing.

> 
> Key.Text is lost when the event KeyRelease is raised.

It is actually not lost, it is just that it should be set only during a 
KeyPress event. gb.gtk is just more clever there.

Regards,

-- 
Benoît Minisini




More information about the User mailing list