Bug 341577: Drag-and-drop of search engines on Mac looks ugly, patch by Phil Ringnalda <philringnalda@gmail.com>, r=me/mconnor

This commit is contained in:
gavin%gavinsharp.com 2006-06-29 01:25:23 +00:00
Родитель a42c58298b
Коммит c4cf1c308c
2 изменённых файлов: 16 добавлений и 23 удалений

Просмотреть файл

@ -140,34 +140,24 @@ var gEngineManagerDialog = {
document.getElementById("cmd_movedown").setAttribute("disabled",
disableButtons || lastSelected);
},
}
};
startDrag: function engineManager_startDrag(aEvent) {
var gDragObserver = {
onDragStart: function (aEvent, aXferData, aDragAction) {
var selectedIndex = gEngineView.selectedIndex;
if (selectedIndex == -1)
return;
var transfer = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
var dragData = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
aXferData.data = new TransferData();
aXferData.data.addDataForFlavour(ENGINE_FLAVOR, selectedIndex.toString());
transfer.addDataFlavor(ENGINE_FLAVOR);
var indexStr = selectedIndex.toString();
dragData.data = indexStr; // 2 bytes per character
transfer.setTransferData(ENGINE_FLAVOR, dragData, indexStr.length * 2);
var transArray = Cc["@mozilla.org/supports-array;1"].
createInstance(Ci.nsISupportsArray);
transfer.QueryInterface(Components.interfaces.nsISupports)
transArray.AppendElement(transfer);
var dragService = Cc["@mozilla.org/widget/dragservice;1"].
getService(Ci.nsIDragService);
dragService.invokeDragSession(aEvent.target, transArray, null,
Ci.nsIDragService.DRAGDROP_ACTION_MOVE);
}
aDragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_MOVE;
},
onDrop: function (aEvent, aXferData, aDragSession) { },
onDragExit: function (aEvent, aDragSession) { },
onDragOver: function (aEvent, aFlavour, aDragSession) { },
getSupportedFlavours: function() { return null; }
};
// "Operation" objects
@ -370,6 +360,7 @@ EngineView.prototype = {
// Redraw, and adjust selection
this.invalidate();
this.selection.clearSelection();
this.selection.select(newIndex);
}
},

Просмотреть файл

@ -55,6 +55,8 @@
<script type="application/x-javascript"
src="chrome://browser/content/search/engineManager.js"/>
<script type="application/x-javascript"
src="chrome://global/content/nsDragAndDrop.js"/>
<commandset id="engineManagerCommandSet">
<command id="cmd_remove"
@ -81,7 +83,7 @@
<tree id="engineList" flex="1" rows="10" hidecolumnpicker="true"
seltype="single" onselect="gEngineManagerDialog.onSelect();">
<treechildren id="engineChildren" flex="1"
ondraggesture="gEngineManagerDialog.startDrag(event);"/>
ondraggesture="nsDragAndDrop.startDrag(event, gDragObserver);"/>
<treecols>
<treecol id="engineName" flex="1" hideheader="true"/>
</treecols>