[Gambas-user] About custom controls in Gambas (was: Watermark on text box)

Tobias Boege taboege at ...626...
Tue Feb 10 23:02:13 CET 2015


On Tue, 10 Feb 2015, Lewis Balentine wrote:
> Hi Tobi ....
> 
> Without entering into the fray regarding the 'watermark':
> You example code provides a nice sample of creating a new control class 
> for those of us that find the process somewhat mystical. Thank you.:-)
> 

Yes, it's one of the last arcane arts in Gambas, as it seems.

Actually, what I did in that project can more precisely be called "extending"
an already existing class (although sometimes "extending" is meant to imply
that a class was actually overridden in the symbol table by an (Inherits-)
descendant; see [0] for the terminology). I just took the TextBox and modi-
fied its behaviour a little.

If you are interested in the topic, you can also look at the "GraphFloodfill"
project in the software farm where I wrote a truly new control class
FMinimalColorChooser by sticking together existing controls on a Form (this
is called "compound control") and later on restricting its interface to a
UserControl, whereby creating the actual exported MinimalColorChooser class.

You can also download the Gambas source tree and look at comp/src/gb.form,
the gb.form component. There are lots of examples (easy to difficult, in
various approaches) of the implementation of custom controls in Gambas --
in fact you will find every control from gb.form in there, written in
Gambas :-) That's where I learned from.

Regards,
Tobi

[0] http://gambaswiki.org/wiki/doc/object-model

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list