[Gambas-user] How can a self made Button UserControl receive the Focus?

Claus Dietrich claus.dietrich at freenet.de
Fri Mar 24 16:22:01 CET 2023


The size of the project is too big for the ML, so I loaded it up

to the cloud: https://magentacloud.de/s/icm7CiGCPBKMRRS

I use a picture class to draw the button with Cairo and load it into a

PictureBox.Picture - property to display it. That's all. Here a brief

overview of the user control class:

Export
Inherits UserControl

Public Const _IsControl As Boolean = True
Public Const _DefaultEvent As String = "Click"
'Declaration of properties
'Declaration of variables
'Declaration of events
......

Public Sub _new()

   hPictureBox = New PictureBox(Me) As "Pic"
   DrawButton(hPictureBox) 'Display Control
   'Me.Proxy = hPictureBox

End

Private Sub DrawButton(DrawControl As PictureBox)
   ..
   With DrawControl
     hPicture = New Picture(.Width, .Height, True)
   End With

   Paint.Begin(hPicture)
      .... paint the button
   Paint.End
   DrawControl.Picture = hPicture

End

If this doesn't fit to a user control which shall receive the focus,

what would be the right way?

Best regards

Claus


Am 24.03.23 um 14:29 schrieb Benoit Minisini:
> Le 24/03/2023 à 14:18, Benoit Minisini a écrit :
>> Le 24/03/2023 à 13:24, Claus Dietrich a écrit :
>>> Hi
>>>
>>> I am currently developing a button user control in Gambas language.
>>>
>>> So it inherits UserControl, is based on a PictureBox and the button 
>>> class
>>>
>>> is part of a "Normal" project type (not "Component").
>>>
>>> My problem: During runtime the self-made button control doesn't receive
>>>
>>> the focus when I hit the Tab-key.
>>>
>>> My Question: How can I fix this?
>>>
>>> Best regards
>>>
>>> Claus
>>>
>>
>> You must have at least something that can takes the focus inside your 
>> UserControl, and make this control the proxy of the UserControl by 
>> assigning the Proxy property.
>>
>
> Mmm... Sorry, I didn't answer your question actually, I have read it 
> too fast.
>
> But you should anyway always give your code inside a project so that 
> anyone can see what you do exactly.
>
> REgards,
>
> -- 
> Benoît Minisini.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230324/6df3096c/attachment.htm>


More information about the User mailing list