[Gambas-user] KeyPress Event not raised in Picture Box

T Lee Davidson t.lee.davidson at gmail.com
Fri Feb 24 02:53:52 CET 2023


On 2/23/23 19:13, Ed & Clare Kelm wrote:
> I have a form with a picture box called picGame, and I want to capture keyboard input when the picture box has the focus.  
> However, the event is never raised.  My test code is:
> 
> Public Sub picGame_KeyPress()
>     Print Key.Text
> End
> 
> I am running 3.18.0 in Xubuntu 16.04.
> 
> What am I doing wrong?
> 
> Thanks!
> 
> Ed K.

You have to make sure the PictureBox has focus.

Neither tabbing to it, nor clicking on it, give it focus. It needs to be done explicitly, eg.:
picGame.SetFocus


-- 
Lee



More information about the User mailing list