[Gambas-user] Finding the Draw event name of controls not in gb.form or gb.gu.base

Bruce Steers bsteers4 at gmail.com
Thu Dec 22 17:10:15 CET 2022


On Thu, 22 Dec 2022 at 13:31, Benoit Minisini <
benoit.minisini at gambas-basic.org> wrote:

> Le 22/12/2022 à 13:21, Bruce Steers a écrit :
> >
> > I have figured out a way to modify controls by simply making a class of
> > the same name and overriding the Draw event.
> >
> > For example Label.class
> > I make a class called Label.class
> > Then by looking at the gb.gui.base/Label.class source i can see that the
> > Draw event is called UserControl_Draw()
> > So in my Label.class I can do the following example to add a gradient
> > background...
> >
> > ' Gambas class file
> >
> > Export
> >
> > Public Sub UserControl_Draw()
> >
> >    Paint.Rectangle(0, 0, Me.W, Me.h)
> >    Paint.Brush = Paint.LinearGradient(0, 0, 0, Me.H, [Color.Yellow,
> > Color.Red], [0, 1])
> >    Paint.Fill
> >    'Paint.Restore
> >    Paint.Background = Me.Foreground
> >
> >    Super.UserControl_Draw
> >
> > End
> >
> > That overrides UserControl_Draw, does my thing, then runs the
> > Super.UserControl_Draw
> >
> > Now my question is for if i want to the a similar thing to say HBox.class
> >
> > I cannot find HBox.class to find the name of the Draw event to override
> it.
> >
> > Is it possible to find the event method names of a native control?
> >
> > Many thanks
> > BruceS
> >
>
> You can do that only for classes that inherit UserControl or
> UserContainer (i.e. controls made with Gambas, and not native controls
> coming from the underlying GUI toolkit).
>
> So you can't do that for HBox. But you can create your own container
> with UserContainer and set its 'Arrangement' property to
> 'Arrange.Horizontal', and you have your own HBox.
>
> Regards,
>
> --
> Benoît Minisini.
>

Brilliant, thank you Ben :)

Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20221222/17d4344c/attachment.htm>


More information about the User mailing list