[view] remove InputTextView

This commit is contained in:
2019-04-05 16:47:16 +03:00
parent b87338cbef
commit 493a319ef5
2 changed files with 1 additions and 73 deletions

View File

@@ -1,69 +0,0 @@
package haxework.view;
import flash.events.Event;
import flash.ui.Keyboard;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.events.KeyboardEvent;
import haxe.Timer;
import flash.events.MouseEvent;
class InputTextField extends TextField {
private var focused:Bool;
public function new() {
super();
//#if flash
type = TextFieldType.INPUT;
//#elseif js
//addEventListener(MouseEvent.CLICK, onMouseClick);
//#end
}
#if js
private function onMouseClick(event:MouseEvent):Void {
focused = true;
border = true;
borderColor = 0x00ff00;
Timer.delay(function() {
stage.addEventListener(MouseEvent.CLICK, onFocusOut);
}, 1);
addEventListener(Event.REMOVED_FROM_STAGE, onFocusOut);
stage.addEventListener(KeyboardEvent.KEY_UP, onStageKeyUp);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onStageKeyDown);
}
private function onStageKeyDown(event:KeyboardEvent):Void {
event.stopPropagation();
event.stopImmediatePropagation();
untyped __js__("window.event.preventDefault()");
}
private function onStageKeyUp(event:KeyboardEvent):Void {
event.stopPropagation();
event.stopImmediatePropagation();
untyped __js__("window.event.preventDefault()");
switch (event.keyCode) {
case Keyboard.BACKSPACE:
text = event.ctrlKey ? "" : text.substring(0, text.length - 1);
case x if (x >= 65 && x <= 90):
text += String.fromCharCode(event.keyCode + (event.shiftKey ? 0 : 32));
case x if (x >= 48 && x <= 57):
text += String.fromCharCode(event.keyCode);
case x if (x >= 96 && x <= 105):
text += String.fromCharCode(event.keyCode - 48);
}
}
private function onFocusOut(_):Void {
if (stage != null) {
stage.removeEventListener(MouseEvent.CLICK, onFocusOut);
stage.removeEventListener(KeyboardEvent.KEY_UP, onStageKeyUp);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onStageKeyDown);
}
focused = false;
border = false;
}
#end
}

View File

@@ -18,6 +18,7 @@ class InputView extends TextView {
public function new() {
super();
textField.type = TextFieldType.INPUT;
textField.addEventListener(Event.CHANGE, onTextChange);
textField.addEventListener(KeyboardEvent.KEY_UP, _onKeyUp);
textField.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
@@ -27,10 +28,6 @@ class InputView extends TextView {
textFormat.align = TextFormatAlign.LEFT;
}
override private function buildTextField():TextField {
return new InputTextField();
}
private function set_hint(value:String):String {
if (hint != value) {
hint = value;