From 58816ad380d703d87e0e09bf54589b5c9330dd87 Mon Sep 17 00:00:00 2001 From: Sartoric Date: Mon, 24 Feb 2014 10:46:52 +0100 Subject: [PATCH 1/2] Update Switch.hx --- src/ru/stablex/ui/widgets/Switch.hx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ru/stablex/ui/widgets/Switch.hx b/src/ru/stablex/ui/widgets/Switch.hx index 23dfef9..2b19aef 100644 --- a/src/ru/stablex/ui/widgets/Switch.hx +++ b/src/ru/stablex/ui/widgets/Switch.hx @@ -136,6 +136,9 @@ class Switch extends Widget{ private inline function _slide (e:MouseEvent) : Void { var dx : Float = this.mouseX - this.slider.left; var startX : Float = this.mouseX; + // Remove the Mouseup event for parent widget + this.removeEventListener(MouseEvent.MOUSE_UP, this._onRelease); // added row + //indicate user is actually moving slider var slided : Bool = false; @@ -174,9 +177,11 @@ class Switch extends Widget{ //remove listeners this.removeEventListener(Event.ENTER_FRAME, fn); Lib.current.stage.removeEventListener(MouseEvent.MOUSE_UP, fnRelease); + // Add the Mouseup event for parent widget + this.addEventListener(MouseEvent.MOUSE_UP, this._onRelease); // added row }; //listen for MOUSE_UP Lib.current.stage.addEventListener(MouseEvent.MOUSE_UP, fnRelease); }//function _slide() -}//class Switch \ No newline at end of file +}//class Switch From ce3950a77a8c835136dc8b1dd34f583dbb41e5f4 Mon Sep 17 00:00:00 2001 From: Sartoric Date: Wed, 26 Feb 2014 18:46:47 +0100 Subject: [PATCH 2/2] Added enabled/disabled property Added the property disabled=false in order to enable/disable input in the textbox. This can be useful in case of editing form that should be "blocked" for some user category, or viceversa --- src/ru/stablex/ui/widgets/InputText.hx | 44 +++++++++++++++----------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/ru/stablex/ui/widgets/InputText.hx b/src/ru/stablex/ui/widgets/InputText.hx index 53b2ac1..8671a81 100644 --- a/src/ru/stablex/ui/widgets/InputText.hx +++ b/src/ru/stablex/ui/widgets/InputText.hx @@ -15,28 +15,32 @@ class InputText extends Text{ * Constructor * */ + public var disabled :Bool = false; + public function new () : Void { super(); - #if !html5 - this.label.type = flash.text.TextFieldType.INPUT; - #else - //due to strange bug we need this hack - this.addEventListener(Event.ADDED_TO_STAGE, function(e:Event){ + if (!disabled){ + #if !html5 this.label.type = flash.text.TextFieldType.INPUT; - Reflect.field(this.label, '__graphics').__surface.style.width = this.w + "px"; - Reflect.field(this.label, '__graphics').__surface.style.height = this.h + "px"; - Reflect.field(this.label, '__graphics').__surface.style.overflow = "hidden"; - if( this.label.wordWrap ){ - Reflect.field(this.label, '__graphics').__surface.style.whiteSpace = "normal"; - }else{ - Reflect.field(this.label, '__graphics').__surface.style.whiteSpace = "nowrap"; - } - }); - #end + #else + //due to strange bug we need this hack + this.addEventListener(Event.ADDED_TO_STAGE, function(e:Event){ + this.label.type = flash.text.TextFieldType.INPUT; + Reflect.field(this.label, '__graphics').__surface.style.width = this.w + "px"; + Reflect.field(this.label, '__graphics').__surface.style.height = this.h + "px"; + Reflect.field(this.label, '__graphics').__surface.style.overflow = "hidden"; + if( this.label.wordWrap ){ + Reflect.field(this.label, '__graphics').__surface.style.whiteSpace = "normal"; + }else{ + Reflect.field(this.label, '__graphics').__surface.style.whiteSpace = "nowrap"; + } + }); + #end - this.label.autoSize = flash.text.TextFieldAutoSize.NONE; - this.format.align = flash.text.TextFormatAlign.LEFT; + this.label.autoSize = flash.text.TextFieldAutoSize.NONE; + this.format.align = flash.text.TextFormatAlign.LEFT; + } }//function new() @@ -59,6 +63,10 @@ class InputText extends Text{ Reflect.field(this.label, '__graphics').__surface.style.whiteSpace = "nowrap"; } #end + if (disabled) + {this.label.type = null;} + else {this.label.type = flash.text.TextFieldType.INPUT;} + }//function refresh() #if html5 @@ -85,4 +93,4 @@ class InputText extends Text{ return super.set_text(txt); }//function set_text() #end -}//class InputText \ No newline at end of file +}//class InputText