Oh, does the paramWidget consumes the event, and so doesn’t pass it to the child…
If I get time, I’ll take a better look at this at the weekend, but right now I don’t think this is going to work for params that your module does not own, unless you want to try to reparent them in the tree…
edit: if I were trying to make this work, my next step would be debugging, I would want to see what methods are being called when and what events are generated and handled by the different widgets… I would hope that would point me in the right direction
Right - child widgets are normally drawn in order, from first added to last since addChild appends. This is the default for Rack widgets. Children added later draw on top of prior children. A widget can control whether it paints under or on top of its children by overriding draw, and changing where it calls its base class draw relative to any drawing that it does.
A widget can draw children in any order it wants to by overriding draw and never calling the base class draw.
Draw order is distinct from input handling. Input events are more complicated due to the recursive dispatch of events, setting the target, etc. I wish the Rack docs went into more detail on the design and protocols for input event handling.
Just to add a little note that might help some readers. TransparentWidget is not called that because it is visually transparent. Transparent in this case only means that mouse clicks pass through it as though it wasn’t there.
If you want to block mouse clicks, you could use an OpaqueWidget and ensure that it doesn’t draw anything. That would be visibly transparent, but would prevent mouse events getting to any widgets that were behind it.
I can still move the knob (even if I see the semi-transparent red layer above the knob).
Removing the draw() function, nothing change, its the same (aside I won’t see the red layer, obviously).
Am I doing it wrong? That would be the easiest way to accomplish what I need…
BUT: since I need to add/remove it dynamically, remove it seems a PAIN: in fact, if later I remove the child, it will remove ALL the children (so, also the param ) Which I don’t want.
Sure there’s a remove child method which returns you the pointer you need to free
So I would keep the weak pointer to your widget as a member then later search for the knob again find its parent search for the weak pointer remove it so you own it and delete it if found or set to null if not found
Sorry, but I don’t get your point. removeChild will remove all the children of the child I’ll remove (in this case, the parent or every widget, so It remove everything).
Did you mean implement my own removeChild? Damn, this is huge: need to manage lot of operations/event and such…
RemoveChild gives a pointer to it, so enumerate it’s children and reinject them into the parent. Make sure to remove them from your wrapper as you go so that they don’t get destroyed when you delete your widget.