[Gambas-user] Re: Treeview data
Benoit Minisini
gambas at ...1...
Sun Feb 26 11:42:58 CET 2006
On Sunday 26 February 2006 08:47, Rohnny Stormo wrote:
> Rohnny Stormo wrote:
> > <How to activate the click event and the other events.
> > <> If I have understod you correct. I make a new class and ex call it
> > <> mytreeview Just the following in the class
> > <>
> > <> INHERITS TreeView
> > <>
> > <> public MyTestString as string
> > <>
> > <> From my form I do as this
> > <>
> > <> public myTree as new mytreeview(me)
> >
> > <<
> > <public myTree as MyTreeView
> > <myTree = new mytreeview(me) AS "myTree"
> > <
> > <If you don't give an event name, you will never get events!
> > <
> > <Regards,
> > <
> > <-- <Benoit Minisini
>
> My Test Project
> 1) Class name cTextBox
> ' Gambas class file
> INHERITS TextBox
>
> PUBLIC Extra AS String
>
>
> PUBLIC SUB _New(x AS Integer, y AS Integer, width AS Integer, height AS
> Integer)
>
> ME.X = x
> ME.Y = y
> ME.Width = width
> ME.Height = height
> ME.Extra = "Hello Extra"
> object.Attach(ME, ME, "me")
> END
> PUBLIC SUB me_keyPress()
>
> message("Internal sub")
>
> END
>
> 2) Form1
> ' Gambas class file
>
> PRIVATE tBox AS CtextBox
> PUBLIC SUB Form_Open()
> tBox = NEW CtextBox(10, 10, 100, 20, ME) AS "tBox"
> END
> PUBLIC SUB tBox_KeyPress()
> Message("External Sub - " & tBox.Extra)
> END
>
>
> This is showing Textbox as it should. It do fire class keypress
> If I remove the object.attach it do fire the form tbox_keypress
>
> How to fire them both?
> First cTextBox_keypress then, if defined , as here it is, tBox_keypress
> from the main form.
>
>
>
> Is it - could it, be possible to have classes that do inherit showing
> as tool in the gambas toolbox?
You can't do that this way. Once the event is raised, you can't intercept it
in the inherited class.
You must put your CTextBox inside another MyTextBox control, i.e. replace
inheritance by composition in terms of OOP.
The CTextBox will raise its KeyPress events, you will get in MyTextBox, and
then MyTextBox will raise its own event.
In the development version, you will use UserControl for implementing such
controls (or UserContainer for containers). See the gb.form component sources
to see many controls implemented this way.
To be put in the toolbox, classes must be inside a component, declared as
EXPORT, and declared in the *.component file. There are other constraints
too...
You must do that by hand at the moment, as the IDE does not support it
transparently at the moment. I didn't document everything yet, as it is not
completely stable.
Look inside the gb.form component sources again to see what I mean.
Regards,
--
Benoit Minisini
More information about the User
mailing list