I have a personal project (a simple text editor) I’ve been working on over several months (when I have the energy and headspace). And I have one feature I’ve been putting off until now, because I knew there might be some issues.
Using Xojo 2021r1.1 for a Desktop project on macOS (10.15.7).
I need to move an instance of an embedded ContainerControl (which contains an HTMLViewer-based editor), which I’ll call AceCC
(which is also attached to a PagePanel using *.EmbedWithinPanel) from within one ContainerControl to a whole different ContainerControl (and attach it to another PagePanel).
In other words, move an active instance of an embedded ContainerControl from a “source” parent Container to another “target” parent Container.
I am able to move my reference for the AceCC
instance from one ContainerControl to the other okay, but when I go to do the second EmbedWithinPanel
call (in the “target” Container), I get an UnsupportedOperationException that says “Cannot embed a closed ContainerControl”
AceCC.EmbedWithinPanel(Self.contentPanel, newPanelIndex, 0, 0, Self.contentPanel.Width, Self.contentPanel.Height)
Note: I am able to interact with the AceCC
instance fine, like to use RemoveHandler
for events in the source ContainerControl, and AddHandler
in the new target ContainerControl, but the final target embed chokes.
During removal of the embedded ContainerControl from the “source” Container, I do some cleanup that involves calling Close
on the AceCC
Container (which I can avoid doing), but I suspect it is the call to the “source” PagePanel.RemovePanelAt that is actually closing the Container in my instance.
What do you folks think?
I do have a workaround in mind, but I would lose some state information inside the AceCC
instance, such as the Undo history. The workaround involves creating a New
instance and copying various property information across, then destroying the original.
Is it possible to keep an embedded ContainerControl from closing when I move it like this?
Any insight or advice would be greatly appreciated.
And thank you for reading through my rambling. I hope it made sense