Miyagi GUI - Help: Movable panel / SubControls

cyberjunk

03-09-2012 22:52:03

Hey there,

I'm using Miyagi Panel class and I've set "Movable = true" and I can move the Panel around. Fine so far.
However, once I add a Label (TextBox, Button, ...) I can not trigger the Panel moving by holding down the button on such a sub control.
Of course: The events get consumed by the SubControl...

My question:
How can I make a Panel movable even if the "mousedown/mousemove/..." events are catched by the subcontrol? (e.g. Label).
I want the Panel to move no matter which subcontrol the mouse actually is on.

I tried to add a event listener to all Mouse and Drag events the Label (subcontrol) offers.
Then calling corresponding event handlers on the Panel class, like:


lblTitle.DragOver += new EventHandler<DragEventArgs>(lblTitle_DragOver);
....

private void lblTitle_DragOver(object sender, DragEventArgs e)
{
DragEventArgs args = new DragEventArgs(e.Data, e.Effect, this);
base.OnDragOver(args);
}


I also tried with the Label itself as "dragSource" (3. argument), just passed e to handler.
And I've added any Mouse/Drag event like the example above.
Still not working. No panel move if the mouse is not exactly on the panel (without a subcontrol).

Any solution?
I bet there is something simple I'm just missing.

Thank you

smiley80

04-09-2012 19:01:13

For labels, you can simply set HitTestVisible to false.

For other controls, i.e. interactive ones, have to do something like this:
child.MouseDown += (s, e) => miyagiSystem.GUIManager.GrabbedControl = panel;

cyberjunk

04-09-2012 23:40:06

Thank you very much, this was exactly what I was looking for and and it works like a charm.
Until now I had figured out another "workaround", but your solution is much better.

My poor solution was to handle the "MouseDrag" event and programatically reset the Location property of the Panel with the offset from the event arguments.
Worked also, but panel was getting "lost" if movement was too fast and your solution is definitely the way to go.