Closed kevinfoley closed 5 years ago
You might try listening for FocusEvent.MOUSE_FOCUS_CHANGE and calling event.preventDefault().
@joshtynjala I tried this, but it doesn't seem to work (the event is never fired):
dragDropTarget.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, onDragDropTargetFocusChange, false, 0, true);
private function onDragDropTargetFocusChange(e:FocusEvent):void {
e.stopImmediatePropagation();
e.preventDefault();
}
Did you mean something else?
That's what I meant. I didn't try it myself before suggesting it, though.
@joshtynjala Since that doesn't work, do you have any other suggestions about how to resolve this?
Unfortunately, no. I may be able to look at this in more detail when I have some time, but that may not be soon.
@joshtynjala After reviewing the code for DefaultFocusManager
, I figured out the correct solution:
//add to stage, not to problem display object. priority should be higher than 0 to make sure this listener is called before the listener in DefaultFocusManager
Starling.current.nativeStage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, onFocusChange, false, 100, true);
private function onFocusChange(e:FocusEvent):void {
if (e.relatedObject == dragDropTarget) {
e.stopImmediatePropagation();
e.preventDefault();
}
}
We have a desktop application which lets the user drag content files into the application window using AIR's NativeDragManager support. This requires setting up a native display object with NativeDragEvent listeners
However, the
dragDropTarget
in the above example interferes with some Feathers features like the PickerList which rely on theDefaultFocusManager
to decide when to close. When we click the picker list button, the popup list appears. When we attempt to click an item in the popup list, theDefaultFocusManager
interprets the click as being focused on thedragDropTarget
sprite. This removes focus from the popup list, which causes it to close immediately without detecting that the user tried to click one of the options.I've tried adding the NativeDragEvents to the native stage or to Starling's nativeOverlay, but neither approach seems to work. How might we resolve this?