示例#1
0
 internal protected virtual void OnDragOver(DragOverEventArgs args)
 {
     if (dragOver != null)
     {
         dragOver(this, args);
     }
 }
示例#2
0
 void HandleB2DragOver(object sender, DragOverEventArgs e)
 {
     if (e.Action == DragDropAction.All)
         e.AllowedAction = DragDropAction.Move;
     else
         e.AllowedAction = e.Action;
 }
示例#3
0
 void HandleDragOver(object sender, DragOverEventArgs e)
 {
     e.AllowedAction = e.Action;
 }
示例#4
0
        void HandleWidgetDragDataReceived(object o, Gtk.DragDataReceivedArgs args)
        {
            dragDataRequests--;

            if (!Util.GetSelectionData (args.SelectionData, dragData)) {
                args.RetVal = false;
                return;
            }

            if (dragDataRequests == 0) {
                if (dragDataForMotion) {
                    DragOverEventArgs da = new DragOverEventArgs (lastDragPosition, dragData, ConvertDragAction (args.Context.Actions));
                    Toolkit.Invoke (delegate {
                        EventSink.OnDragOver (da);
                    });
                    Gdk.Drag.Status (args.Context, ConvertDragAction (da.AllowedAction), args.Time);
                }
                else {
                    // Use Context.Action here since that's the action selected in DragOver
                    var cda = ConvertDragAction (args.Context.Action);
                    DragEventArgs da = new DragEventArgs (lastDragPosition, dragData, cda);
                    Toolkit.Invoke (delegate {
                        EventSink.OnDragDrop (da);
                    });
                    Gtk.Drag.Finish (args.Context, da.Success, cda == DragDropAction.Move, args.Time);
                }
            }
        }
示例#5
0
        internal bool DoDragDataReceived(Gdk.DragContext context, int x, int y, Gtk.SelectionData selectionData, uint info, uint time)
        {
            if (DragDropInfo.DragDataRequests == 0) {
                // Got the data without requesting it. Create the datastore here
                DragDropInfo.DragData = new TransferDataStore ();
                DragDropInfo.LastDragPosition = new Point (x, y);
                DragDropInfo.DragDataRequests = 1;
            }

            DragDropInfo.DragDataRequests--;

            if (!Util.GetSelectionData (ApplicationContext, selectionData, DragDropInfo.DragData)) {
                return false;
            }

            if (DragDropInfo.DragDataRequests == 0) {
                if (DragDropInfo.DragDataForMotion) {
                    // If no specific action is set, it means that no key has been pressed.
                    // In that case, use Move or Copy or Link as default (when allowed, in this order).
                    var cact = ConvertDragAction (context.Actions);
                    if (cact != DragDropAction.Copy && cact != DragDropAction.Move && cact != DragDropAction.Link) {
                        if (cact.HasFlag (DragDropAction.Move))
                            cact = DragDropAction.Move;
                        else if (cact.HasFlag (DragDropAction.Copy))
                            cact = DragDropAction.Copy;
                        else if (cact.HasFlag (DragDropAction.Link))
                            cact = DragDropAction.Link;
                        else
                            cact = DragDropAction.None;
                    }

                    DragOverEventArgs da = new DragOverEventArgs (DragDropInfo.LastDragPosition, DragDropInfo.DragData, cact);
                    ApplicationContext.InvokeUserCode (delegate {
                        EventSink.OnDragOver (da);
                    });
                    OnSetDragStatus (context, (int)DragDropInfo.LastDragPosition.X, (int)DragDropInfo.LastDragPosition.Y, time, ConvertDragAction (da.AllowedAction));
                    return true;
                }
                else {
                    // Use Context.Action here since that's the action selected in DragOver
                    var cda = ConvertDragAction (context.Action);
                    DragEventArgs da = new DragEventArgs (DragDropInfo.LastDragPosition, DragDropInfo.DragData, cda);
                    ApplicationContext.InvokeUserCode (delegate {
                        EventSink.OnDragDrop (da);
                    });
                    Gtk.Drag.Finish (context, da.Success, cda == DragDropAction.Move, time);
                    return true;
                }
            } else
                return false;
        }
示例#6
0
文件: Widget.cs 项目: joncham/xwt
 /// <summary>
 /// Raises the DragOver event.
 /// </summary>
 /// <param name='args'>
 /// Arguments.
 /// </param>
 protected internal virtual void OnDragOver(DragOverEventArgs args)
 {
     if (dragOver != null)
         dragOver (this, args);
 }
示例#7
0
文件: Widget.cs 项目: joncham/xwt
 public void OnDragOver(DragOverEventArgs args)
 {
     Parent.OnDragOver (args);
 }
示例#8
0
        internal bool DoDragDataReceived(Gdk.DragContext context, int x, int y, Gtk.SelectionData selectionData, uint info, uint time)
        {
            if (DragDropInfo.DragDataRequests == 0) {
                // Got the data without requesting it. Create the datastore here
                DragDropInfo.DragData = new TransferDataStore ();
                DragDropInfo.LastDragPosition = new Point (x, y);
                DragDropInfo.DragDataRequests = 1;
            }

            DragDropInfo.DragDataRequests--;

            if (!Util.GetSelectionData (selectionData, DragDropInfo.DragData)) {
                return false;
            }

            if (DragDropInfo.DragDataRequests == 0) {
                if (DragDropInfo.DragDataForMotion) {
                    // This is a workaround to what seems to be a mac gtk bug.
                    // Suggested action is set to all when no control key is pressed
                    var cact = ConvertDragAction (context.Actions);
                    if (cact == DragDropAction.All)
                        cact = DragDropAction.Move;

                    DragOverEventArgs da = new DragOverEventArgs (DragDropInfo.LastDragPosition, DragDropInfo.DragData, cact);
                    Toolkit.Invoke (delegate {
                        EventSink.OnDragOver (da);
                    });
                    OnSetDragStatus (context, (int)DragDropInfo.LastDragPosition.X, (int)DragDropInfo.LastDragPosition.Y, time, ConvertDragAction (da.AllowedAction));
                    return true;
                }
                else {
                    // Use Context.Action here since that's the action selected in DragOver
                    var cda = ConvertDragAction (context.Action);
                    DragEventArgs da = new DragEventArgs (DragDropInfo.LastDragPosition, DragDropInfo.DragData, cda);
                    Toolkit.Invoke (delegate {
                        EventSink.OnDragDrop (da);
                    });
                    Gtk.Drag.Finish (context, da.Success, cda == DragDropAction.Move, time);
                    return true;
                }
            } else
                return false;
        }
示例#9
0
 public void OnDragOver(DragOverEventArgs args)
 {
     Parent.OnDragOver(args);
 }
示例#10
0
 protected override void OnDragOver(DragOverEventArgs args)
 {
     args.AllowedAction = DragDropAction.Link;
 }
示例#11
0
        void HandleWidgetDragDataReceived(object o, Gtk.DragDataReceivedArgs args)
        {
            dragDataRequests--;

            string type = Util.AtomToType (args.SelectionData.Target.Name);
            if (type == null) {
                args.RetVal = false;
                return;
            }

            if (args.SelectionData.Length > 0) {
                if (type == TransferDataType.Text)
                    dragData.AddText (args.SelectionData.Text);
                else if (args.SelectionData.TargetsIncludeImage (false))
                    dragData.AddImage (WidgetRegistry.CreateFrontend<Xwt.Drawing.Image> (args.SelectionData.Pixbuf));
                else if (type == TransferDataType.Uri) {
                    var uris = System.Text.Encoding.UTF8.GetString (args.SelectionData.Data).Split ('\n').Where (u => !string.IsNullOrEmpty(u)).Select (u => new Uri (u)).ToArray ();
                    dragData.AddUris (uris);
                }
                else
                    dragData.AddValue (type, args.SelectionData.Data);
            }
            if (dragDataRequests == 0) {
                if (dragDataForMotion) {
                    DragOverEventArgs da = new DragOverEventArgs (lastDragPosition, dragData, ConvertDragAction (args.Context.Actions));
                    EventSink.OnDragOver (da);
                    Gdk.Drag.Status (args.Context, ConvertDragAction (da.AllowedAction), args.Time);
                }
                else {
                    // Use Context.Action here since that's the action selected in DragOver
                    var cda = ConvertDragAction (args.Context.Action);
                    DragEventArgs da = new DragEventArgs (lastDragPosition, dragData, cda);
                    EventSink.OnDragDrop (da);
                    Gtk.Drag.Finish (args.Context, da.Success, cda == DragDropAction.Move, args.Time);
                }
            }
        }