PDA

View Full Version : Context Menu on Drag



archmisha
6 Aug 2009, 11:46 PM
Hi,
I want to enable the option like in windows to drag some item (suppose from a grid) with the right mouse button onto some grid or tree or whatever, then when mouse released to display a context menu - copy / move. Just like files and folders in windows.
Currently i was able only to do static (non dragable) context menu, or left mouse drag - which doesnt present any option to the user upon mouse release.

Any ideas please?
thanks

Condor
7 Aug 2009, 12:01 AM
Dragging is usually restricted to the primary mouse button (remember the old Macs with only one mouse button?).

If you want to support right mouse button dragging you will have to initialize the DragZone with primaryButtonOnly:false.
You would have to program the menu that is shown after right mouse button drop yourself.

archmisha
7 Aug 2009, 1:36 AM
Thank you.
2 follow up questions:
1)


this.on('render', function(v)
{
v.getEl().dragZone = new Ext.grid.GridDragZone(v,
{
// didnt work here, so set it afterwards with Ext.apply
// primaryButtonOnly: false, // to be able to drag with right mouse button

// @override
onInitDrag : function(x, y)
{
...
},

// Provide coordinates for the proxy to slide back to on failed drag.
// This is the original XY coordinates of the draggable element.
getRepairXY: function()
{
return this.dragData.repairXY;
}
});

// wasnt able to set it otherwise
Ext.apply(v.getEl().dragZone, {primaryButtonOnly: false});
});
When i added the primaryButtonOnly as property when creating GridDragZone seems it didnt work, and only if later i was doing the Ext.apply it catches up. Was i setting it wrong in the first try?

2) Now i got the drag initiated on my grid with right mouse click but i had a context menu too. So when i finish dragging now, the context menu sometimes appears.
Is it possible in the context menu event to know if it was actually drag and return immediately? Or do i have to set up some variable when starting drag and in the context menu check it out and reset it? (which is kinda ugly)

thanks again :)

Condor
7 Aug 2009, 1:57 AM
1. I would say it's a bug. The DragSource constructor doesn't pass the padding, maintainOffset and primaryButtonOnly config options to it's DDProxy superclass constructor.

2. Please explain a bit better...

archmisha
7 Aug 2009, 2:11 AM
Sorry,

I have a grid.
It got context menu event.
Now I added the dragging event for the right mouse click.

So when i drag both event occur - the dragging and the right mouse context menu.

So i think i have to check in the context menu event some how whether it is a drag event or a pure context event.

Condor
7 Aug 2009, 2:53 AM
I would use a DelayedTask to show the context menu and cancel the task on startdrag.