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

Ed & Clare Kelm twopilots at interisland.net
Fri Feb 24 06:25:42 CET 2023



On 2/23/23 5:53 PM, T Lee Davidson wrote:
> 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
>
>
Excellent!  That works!

Many thanks, Lee.



More information about the User mailing list