fixes for html5
This commit is contained in:
@@ -28,7 +28,11 @@ class ButtonView extends LabelView {
|
||||
dispatcher = new Dispatcher<ButtonViewListener<Dynamic>>();
|
||||
content.buttonMode = true;
|
||||
content.mouseChildren = false;
|
||||
#if js
|
||||
content.addEventListener(MouseEvent.MOUSE_UP, onMouseClick);
|
||||
#else
|
||||
content.addEventListener(MouseEvent.CLICK, onMouseClick);
|
||||
#end
|
||||
#if !mobile
|
||||
content.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
|
||||
content.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
|
||||
@@ -54,15 +58,19 @@ class ButtonView extends LabelView {
|
||||
|
||||
private function onMouseDown(event:MouseEvent):Void {
|
||||
downed = true;
|
||||
if (content.stage != null) {
|
||||
content.stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private function onMouseUp(event:MouseEvent):Void {
|
||||
downed = false;
|
||||
if (content.stage != null) {
|
||||
content.stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private function pressCaller(listener:ButtonViewListener<Dynamic>):Void {
|
||||
try {listener.onPress(this);} catch (error:Dynamic) L.e("onPress", "", error);
|
||||
@@ -93,6 +101,7 @@ class ButtonView extends LabelView {
|
||||
public function dispose():Void {
|
||||
dispatcher.removeAllListeners();
|
||||
content.removeEventListener(MouseEvent.CLICK, onMouseClick);
|
||||
content.removeEventListener(MouseEvent.MOUSE_UP, onMouseClick);
|
||||
content.removeEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
|
||||
content.removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
|
||||
content.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
|
||||
|
||||
@@ -36,6 +36,8 @@ class TextView extends SpriteView implements ITextView<Sprite, TextField> {
|
||||
textField.width = 1;
|
||||
textField.height = 1;
|
||||
textField.wordWrap = true;
|
||||
//textField.borderColor = 0x00ff00;
|
||||
//textField.border = true;
|
||||
textFormat = textField.defaultTextFormat;
|
||||
textFormat.font = "Arial";
|
||||
textFormat.size = 16;
|
||||
@@ -146,6 +148,7 @@ class TextView extends SpriteView implements ITextView<Sprite, TextField> {
|
||||
if (t != null) textField.text = t;
|
||||
textField.setTextFormat(textFormat);
|
||||
if (contentSize && !Std.is(skin, ISize)) {
|
||||
#if html5 textField.height = textField.textHeight; #end
|
||||
width = textField.width + paddings * 2;
|
||||
height = textField.height + paddings * 2;
|
||||
textField.x = paddings;
|
||||
|
||||
Reference in New Issue
Block a user