protected override bool OnDragDrop(Gdk.DragContext context, int x, int y, uint time) { ActionPaletteItem dropped = DND.Drop(context, null, time) as ActionPaletteItem; if (dropped == null) { return(false); } if (dropped.Node.Type != Gtk.UIManagerItemType.Menuitem && dropped.Node.Type != Gtk.UIManagerItemType.Menu && dropped.Node.Type != Gtk.UIManagerItemType.Toolitem && dropped.Node.Type != Gtk.UIManagerItemType.Separator) { return(false); } ActionTreeNode newNode = null; // Toolitems are copied, not moved using (wrapper.UndoManager.AtomicChange) { if (dropped.Node.ParentNode != null && dropped.Node.Type != Gtk.UIManagerItemType.Toolitem) { if (dropIndex < nodes.Count) { // Do nothing if trying to drop the node over the same node ActionTreeNode dropNode = nodes [dropIndex]; if (dropNode == dropped.Node) { return(false); } dropped.Node.ParentNode.Children.Remove(dropped.Node); // The drop position may have changed after removing the dropped node, // so get it again. dropIndex = nodes.IndexOf(dropNode); nodes.Insert(dropIndex, dropped.Node); } else { dropped.Node.ParentNode.Children.Remove(dropped.Node); nodes.Add(dropped.Node); dropIndex = nodes.Count - 1; } } else { newNode = new ActionTreeNode(Gtk.UIManagerItemType.Menuitem, null, dropped.Node.Action); nodes.Insert(dropIndex, newNode); } // Select the dropped node ActionMenuItem mi = (ActionMenuItem)menuItems [dropIndex]; mi.Select(); } return(base.OnDragDrop(context, x, y, time)); }
void FixedDragDrop(object obj, Gtk.DragDropArgs args) { Gtk.Widget w = DND.Drop(args.Context, gtkfixed, args.Time); Widget ww = Widget.Lookup(w); if (ww != null) { gtkfixed.Put(w, args.X - DND.DragHotX, args.Y - DND.DragHotY); NotifyChildAdded(w); args.RetVal = true; ww.Select(); } }
protected override bool OnDragDrop(Gdk.DragContext context, int x, int y, uint time) { ActionPaletteItem dropped = DND.Drop(context, null, time) as ActionPaletteItem; if (dropped == null) { return(false); } if (dropped.Node.Type != Gtk.UIManagerItemType.Menuitem && dropped.Node.Type != Gtk.UIManagerItemType.Menu && dropped.Node.Type != Gtk.UIManagerItemType.Toolitem && dropped.Node.Type != Gtk.UIManagerItemType.Separator) { return(false); } ActionTreeNode newNode = dropped.Node; if (dropped.Node.Type == Gtk.UIManagerItemType.Toolitem) { newNode = newNode.Clone(); newNode.Type = Gtk.UIManagerItemType.Menuitem; } Widget wrapper = Widget.Lookup(this); using (wrapper.UndoManager.AtomicChange) { if (dropIndex < actionTree.Children.Count) { // Do nothing if trying to drop the node over the same node ActionTreeNode dropNode = actionTree.Children [dropIndex]; if (dropNode == dropped.Node) { return(false); } if (newNode.ParentNode != null) { newNode.ParentNode.Children.Remove(newNode); } // The drop position may have changed after removing the dropped node, // so get it again. dropIndex = actionTree.Children.IndexOf(dropNode); actionTree.Children.Insert(dropIndex, newNode); } else { if (newNode.ParentNode != null) { newNode.ParentNode.Children.Remove(newNode); } actionTree.Children.Add(newNode); dropIndex = actionTree.Children.Count - 1; } // Select the dropped node ActionMenuItem mi = (ActionMenuItem)menuItems [dropIndex]; mi.Select(); } return(base.OnDragDrop(context, x, y, time)); }