I just fixed my first issue in basic component. Let me know if it's ok. I used classList api to do this. :) I did also bindable "selected" property.
Piotr 2017-01-15 22:09 GMT+01:00 <pio...@apache.org>: > Repository: flex-asjs > Updated Branches: > refs/heads/develop 8018076b5 -> f29c2a480 > > > FLEX-35243 - Fix problem with unselecting ToggleTextButton > - Use classList.toggle api in order to switch between selected and > unselected state > - Make ToggleTextButton responsive in case of selecting it from code > > > Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo > Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/f29c2a48 > Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/f29c2a48 > Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/f29c2a48 > > Branch: refs/heads/develop > Commit: f29c2a480c8b9080516cb180bb2c30650420d092 > Parents: 8018076 > Author: piotrz <pio...@apache.org> > Authored: Sun Jan 15 22:09:17 2017 +0100 > Committer: piotrz <pio...@apache.org> > Committed: Sun Jan 15 22:09:17 2017 +0100 > > ---------------------------------------------------------------------- > .../org/apache/flex/html/ToggleTextButton.as | 55 +++++--------------- > 1 file changed, 12 insertions(+), 43 deletions(-) > ---------------------------------------------------------------------- > > > http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ > f29c2a48/frameworks/projects/HTML/src/main/flex/org/apache/ > flex/html/ToggleTextButton.as > ---------------------------------------------------------------------- > diff --git > a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ToggleTextButton.as > b/frameworks/projects/HTML/src/main/flex/org/apache/flex/ > html/ToggleTextButton.as > index 53f4a7b..b9d1050 100644 > --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/ > html/ToggleTextButton.as > +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/ > html/ToggleTextButton.as > @@ -94,10 +94,7 @@ package org.apache.flex.html > } > > COMPILE::JS > - private var _selected:Boolean; > - > - COMPILE::JS > - private var SELECTED:String = "selected"; > + private var _selected:Boolean = false; > > [Bindable("change")] > /** > @@ -128,6 +125,8 @@ package org.apache.flex.html > COMPILE::SWF > { > IToggleButtonModel(model).selected = value; > + > + dispatchEvent(new Event("change")); > } > COMPILE::JS > { > @@ -135,52 +134,24 @@ package org.apache.flex.html > { > _selected = value; > > - var className:String = this.className; > - var typeNames:String = this.typeNames; > - if (value) { > - if (typeNames.indexOf(SELECTED) == -1) { > - typeNames = typeNames + SELECTED; > - if (className) > - element.className = typeNames + ' ' + > className; > - else > - element.className = typeNames; > - } > - } > - else { > - if (typeNames.indexOf(SELECTED) == > typeNames.length - SELECTED.length) { > - typeNames = typeNames.substring(0, > typeNames.length - SELECTED.length); > - if (className) > - element.className = typeNames + ' ' + > className; > - else > - element.className = typeNames; > - } > - } > + element.classList.toggle("toggleTextButton_Selected", > _selected == true); > + element.classList.toggle("toggleTextButton", > _selected == false); > + typeNames = element.className; > + > + dispatchEvent(new Event("change")); > } > } > } > > - /** > - * @private > - * add another class selector > - */ > - override public function get className():String > - { > - // we don't have a model yet so just pass through otherwise > you will loop > - if (!parent) > - return super.className; > - > - var name:String = super.className; > - if (selected) > - return "toggleTextButton_Selected" + (name ? " " + name : > ""); > - else > - return "toggleTextButton" + (name ? " " + name : ""); > - } > - > COMPILE::JS > override protected function createElement():WrappedHTMLElement > { > super.createElement(); > element.addEventListener("click", clickHandler, false); > + element.classList.toggle("toggleTextButton_Selected", > _selected == true); > + element.classList.toggle("toggleTextButton", _selected == > false); > + typeNames = element.className; > + > return element; > } > > @@ -188,14 +159,12 @@ package org.apache.flex.html > private function clickHandler(event:Event):void > { > selected = !selected; > - dispatchEvent(new Event("change")); > } > > COMPILE::SWF > private function internalMouseHandler(event:MouseEvent) : void > { > selected = !selected; > - dispatchEvent(new Event("change")); > } > } > } > > -- Greetings Piotr Zarzycki Flex/AIR/.NET Developer mobile: +48 880 859 557 e-mail: piotrzarzyck...@gmail.com skype: zarzycki10 LinkedIn: http://www.linkedin.com/piotrzarzycki <https://pl.linkedin.com/in/piotr-zarzycki-92a53552>