EmbedWithin event in window

I have a window with a containerControl (C1) using embedWithin of another containerControl (C2) which contains some text fields. Everything works fine, except the event definition in C2 (called after a textfield has changed) does not go through to the window to call a window method.
I want to tell the window that some data have changed.
Is there a way to do that or can I do it in a different way ?

You could create an Event Definition on the ContainerControl that you’re embedding then use AddHandler when setting it up to map that Event Definition to a method on your Window.

var myContainer as new ContainerControl1
myContainer.EmbedWithin( Self, 0, 0, Self.Width, Self.Height )
AddHandler myContainer.DataChanged, AddressOf ReceiveDataMethod
1 Like

thank’s Anthony, I will try and let you know

the way I’m doing it does not work with AddHandler … I’m passing a containerControl to the window and do an embedWithin, but at this point, the passed containerControl is only known as containerControl. I can pass containerControls with different objects, so I do not know the name of the containerControl ( all I need is the containerControl content ), of corse I can pass the name if that leads to a solution.

What I’m trying to do is to have a common window, pass a containerControl where container objects are use for data entry. everything works fine, except I can’t call a window method.

Is there a way to do it or do I have to rethink of redesigning ?

i think you are looking for a class interface.
there you can add a method as example “save”.
in the container control you select this interface.
the container control could save data stand-alone or you could give a jsonitem byref and it appends the data there and the whole storage is made outside.

if you use the same interface at all different container controls each have the
methods from the shared interface and you can also iterate through all if you have a list with the type of this interface.

thank’s Markus,
this is too much effort for my problem, so I did a redesign of my problem.
Inheriting a window would solve so many of my problems, but for now I have to stay with copy and paste.

If you don’t feel like implementing an event definition, simply add a computer property to the window, say “TextField1Updated as String”, and modify it from your TextField1.TextChange event handler:

Window1.TextField1.Updated = me.Text

It will simply echo the TextField TextChange, so you get it from the window.

it is not that easy, I think.
I embed a container control into a window, it is a universal maintenance window, could be any name, so I don’t know if it is possible to call a window Method if I do not know the window name.

Then call a global computed variable created in a module.

It can be called from anywhere.

ok, that’s possible, I will try

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.