--- In [email protected], "Jim Cook" <[EMAIL PROTECTED]> wrote:
>
> Conversely, if I could just change the copy/reject/move cursors to use
> a small trashcan icon, that might be preferable. I haven't seen a way
> to stylize these cursors outside of a stylesheet. Is there a way to
> change them programmatically?
I'm making progress on my problem. I've decided to change the icon
associated with the cursor during a drag event. Here is what I have so
far. It seems to work, but I'll keep an eye out for side-effects. There
is a slight pause when changing the styles that interferes with a really
smooth drag in and out of the initiator.
To use the class, you instantiate it passing in a component that extends
ListBase.
i.e: new DragToNowhere (someGrid);
<code>
class DragToNowhere {
[Embed(source='/assets/images/icons/iconTrash.png')]
private var iconTrashCan:Class;
private var oldStyles:Object = {};
public function DragToNowhere(list:ListBase) {
list.dragEnabled = true;
list.addEventListener(DragEvent.DRAG_EXIT, replaceStyles);
list.addEventListener(DragEvent.DRAG_ENTER, restoreStyles);
list.addEventListener(DragEvent.DRAG_COMPLETE, restoreStyles);
}
private function replaceStyles(event:DragEvent) : void {
if (!this.oldStyles.replaced) {
var styleSheet:CSSStyleDeclaration =
StyleManager.getStyleDeclaration("DragManager");
this.oldStyles.copyCursor =
styleSheet.getStyle('copyCursor');
this.oldStyles.moveCursor =
styleSheet.getStyle('moveCursor');
this.oldStyles.rejectCursor =
styleSheet.getStyle('rejectCursor');
styleSheet.setStyle('copyCursor', iconTrashCan);
styleSheet.setStyle('moveCursor', iconTrashCan);
styleSheet.setStyle('rejectCursor', iconTrashCan);
}
this.oldStyles.replaced = true;
}
private function restoreStyles(event:DragEvent) : void {
if (this.oldStyles.replaced) {
var styleSheet:CSSStyleDeclaration =
StyleManager.getStyleDeclaration("DragManager");
styleSheet.setStyle('copyCursor',
this.oldStyles.copyCursor);
styleSheet.setStyle('moveCursor',
this.oldStyles.moveCursor);
styleSheet.setStyle('rejectCursor',
this.oldStyles.rejectCursor);
this.oldStyles.replaced = false;
}
}
}
</code>