Change ContainerControl order on-the-fly ?

I created a graphic/control user interface in using drag-and-drop concept.
I use ContainerControl() for creating my own (graphic) interface items ; I use also a canvas to draw and manage them (“EmbedWithin”). No problem.
In my app, when the user wants to create a new object, I create a new ContainerControl (from an array, of course) on-the-fly.
But the last ContainerControl created is always over (front) the others. And if the user wants to move the first ContainerControl, this one will be behind/back the others. Not good at all !
Is it possible to change the order (front/back) of ControlElement or Control items on-the-fly ?

Thanx for your help.

Not without removing them all the recreating them in a different order
They don’t have a z-order property

Argh ! Too complex because each instance has got its own properties.
Another way is to use a Canvas Object with the apparence of the ContainerControl (by using DrawInto) and move it in front of them during the drag and drop. But another problem occurs : all mouse events from the ContainerControl stop and - when I move the Canvas in front of the ContainerControl - impossible to get “Mousedrag event” from the Canvas.
I would like to do that :

  • Capture the “Mouse Down” event from the ContainerControl
  • Move the Canvas in front of my ContainerControl and set visible to false (The Canvas takes the appearance of the ContainerControl)
  • But, problems are : When I set ContainerControl.visible to false, all MouseDrag events doesn’t work. And impossible to get Mouse events because the first MouseDown was fired by the ContainerControl, not by the Canvas placed on the same position.
    Do you know a way to transmit/fire mousedrag event to the canvas ?

For the controls in the Windows control libary, you probably should not be layering controls. I am not sure if this applies to ContainerControls but generally Windows does not like you layering controls like this. I’m not so sure about Mac and Linux though. Would it be possible for you to use a PagePanel and not layer your container controls.

Here is an Xippet I made for embedding controls (this might help you make your embedding of containercontrols look cleaner):

You should probably program your own custom container control, if you are that desperate. Maybe you could program your own interface or use XojoScript with IDE to generate your own containercontrol, by adding grouped controls, through code. Though, I bet that would take a long time to program, and may bump into unexpected limitations. If I am right, I believe you cannot even institute certain controls through code but have to place these down on the window.

Sorry if this is all useless and nonsense but I have tried to help

[quote=50111:@Dominik Fusina]Argh ! Too complex because each instance has got its own properties.
You should look up DragPics
It’s all one big canvas but lets you drag drop & reorder images on the fly
It’s really “the right way” to do this - lets you layer things however you want - etc.
The “data” for it is stored independent of the on screen presentation.
So how its drawn is not dependent on how the data is stored and the data is not stored in the controls that make up the on screen view

YES ! I found a way.
I can simulate a reorder during a drag&drop with a Canvas.
As I said, if you set the ContainerControl.visible to false, all events (specially mouseDrag) are lost. To keep then, I created my own invisible method : I move the ContainerControl outside a visible area (x = -3000). Events are kept. I can move a canvas (image copy of ContainerControl) in front of all elements. When I drop it, I hide the Canvas and move the ContainerControl in the right place. That’s all.
So, if you want to keep events, don’t use Visible property ! :wink: