Skip to content

Commit

Permalink
EditManager: handle Event.CLEAR to delete the current selection
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Jan 13, 2022
1 parent a2483b2 commit b2d1357
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/moonshine/editor/text/managers/EditManager.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import moonshine.editor.text.utils.TextEditorUtil;
import moonshine.editor.text.utils.TextUtil;
import openfl.errors.ArgumentError;
import openfl.errors.RangeError;
import openfl.events.Event;
import openfl.events.KeyboardEvent;
import openfl.events.TextEvent;
import openfl.ui.Keyboard;
Expand All @@ -45,6 +46,7 @@ class EditManager {
_textEditor.addEventListener(TextEditorChangeEvent.TEXT_CHANGE, editManager_textEditor_textChangePriorityHandler, false, 100, true);
_textEditor.addEventListener(TextEditorChangeEvent.TEXT_CHANGE, editManager_textEditor_textChangeHandler, false, 0, true);
_textEditor.addEventListener(TextEditorEvent.SELECTION_CHANGE, editManager_textEditor_selectionChangeHandler, false, 0, true);
_textEditor.addEventListener(Event.CLEAR, editManager_textEditor_clearHandler, false, 0, true);
}

private var _textEditor:TextEditor;
Expand Down Expand Up @@ -798,4 +800,11 @@ class EditManager {
}
}
}

private function editManager_textEditor_clearHandler(event:Event):Void {
var change = TextEditorUtil.deleteSelection(_textEditor);
if (change != null) {
_textEditor.dispatchEvent(new TextEditorChangeEvent(TextEditorChangeEvent.TEXT_CHANGE, [change]));
}
}
}

0 comments on commit b2d1357

Please sign in to comment.