There seemed to be a bug in how ColorSpectrumMouseController and the other ColorSpectrum classes worked where as soon as you started dragging the thumb, it would fire a change event and close the ColorSpectrumPopUp. And that would also leave the mouseMove handlers listening because the mouseUp would not occur over the popup. Then the next time you opened the popup, as soon as you moved the mouse over the popup, the mouseMove handler would see it, change the color, fire the change event and the popup would immediately close.
If there was some other way this was supposed to be handled, let me know and/or make the required changes. It was blocking Pashmina and I only had a short period of time to do what I thought was the obvious solution (fire thumbDown/Up events so that the popup closing logic would know that change events are occurring as part of a drag and not close the popup). -Alex On 1/20/20, 1:06 AM, "Yishay Weiss" <[email protected]> wrote: Oh, I see that you used it. Ignore my last comment. ________________________________ From: Yishay Weiss <[email protected]> Sent: Monday, January 20, 2020 11:04:29 AM To: [email protected] <[email protected]>; [email protected] <[email protected]> Subject: RE: [royale-asjs] branch develop updated: handle dragging thumb. Should fix #687 This was supposed to be covered in royale-asjs\frameworks\projects\Basic\src\main\royale\org\apache\royale\html\beads\controllers\ColorSpectrumMouseController.as From: [email protected]<mailto:[email protected]> Sent: Monday, January 20, 2020 10:47 AM To: [email protected]<mailto:[email protected]> Subject: [royale-asjs] branch develop updated: handle dragging thumb. Should fix #687 This is an automated email from the ASF dual-hosted git repository. aharui pushed a commit to branch develop in repository https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitbox.apache.org%2Frepos%2Fasf%2Froyale-asjs.git&data=02%7C01%7Caharui%40adobe.com%7C381d06e90ac04b77790f08d79d88085f%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637151079896233591&sdata=Gr9SVpoGyF9yalYCt%2BtiXt0%2FOy1aohmrQMJ5%2B0TpQe8%3D&reserved=0 The following commit(s) were added to refs/heads/develop by this push: new c14e8d8 handle dragging thumb. Should fix #687 c14e8d8 is described below commit c14e8d8e0c9ccf2cc216a41e6907f2950fdf75e1 Author: Alex Harui <[email protected]> AuthorDate: Mon Jan 20 00:47:01 2020 -0800 handle dragging thumb. Should fix #687 --- .../beads/controllers/ColorSpectrumMouseController.as | 6 +++++- .../royale/html/supportClasses/ColorPickerPopUp.as | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/ColorSpectrumMouseController.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/ColorSpectrumMouseController.as index 0667663..1eeddde 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/ColorSpectrumMouseController.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/ColorSpectrumMouseController.as @@ -24,7 +24,9 @@ package org.apache.royale.html.beads.controllers import org.apache.royale.core.IStrandWithModel; import org.apache.royale.core.IStrandWithModelView; import org.apache.royale.core.IUIBase; - import org.apache.royale.events.MouseEvent; + import org.apache.royale.events.Event; + import org.apache.royale.events.IEventDispatcher; + import org.apache.royale.events.MouseEvent; import org.apache.royale.html.beads.ISliderView; import org.apache.royale.utils.HSV; import org.apache.royale.utils.hsvToHex; @@ -118,6 +120,7 @@ package org.apache.royale.html.beads.controllers { sliderView.track.addEventListener(MouseEvent.MOUSE_MOVE, thumbMoveHandler); sliderView.track.addEventListener(MouseEvent.MOUSE_UP, thumbUpHandler); + (_strand as IEventDispatcher).dispatchEvent(new Event("thumbDown")); } private function thumbMoveHandler(event:MouseEvent):void @@ -131,6 +134,7 @@ package org.apache.royale.html.beads.controllers private function thumbUpHandler(event:MouseEvent):void { + (_strand as IEventDispatcher).dispatchEvent(new Event("thumbUp")); sliderView.track.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMoveHandler); sliderView.track.removeEventListener(MouseEvent.MOUSE_UP, thumbUpHandler); } diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUp.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUp.as index 8c01fa1..b8ad92b 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUp.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUp.as @@ -83,13 +83,30 @@ package org.apache.royale.html.supportClasses var colorSpectrumModel:IColorSpectrumModel = loadBeadFromValuesManager(IColorSpectrumModel, "iColorSpectrumModel", colorSpectrum) as IColorSpectrumModel; colorSpectrumModel.baseColor = (value as IColorModel).color; (colorSpectrum as IEventDispatcher).addEventListener("change", colorSpectrumChangeHandler); + (colorSpectrum as IEventDispatcher).addEventListener("thumbDown", colorSpectrumThumbDownHandler); + (colorSpectrum as IEventDispatcher).addEventListener("thumbUp", colorSpectrumThumbUpHandler); } + private var draggingThumb:Boolean; + protected function colorSpectrumChangeHandler(event:Event):void { (model as IColorModel).color = colorSpectrum.hsvModifiedColor; - dispatchEvent(new Event("change")); + if (!draggingThumb) + dispatchEvent(new Event("change")); } + + protected function colorSpectrumThumbDownHandler(event:Event):void + { + draggingThumb = true; + } + + protected function colorSpectrumThumbUpHandler(event:Event):void + { + draggingThumb = false; + (model as IColorModel).color = colorSpectrum.hsvModifiedColor; + dispatchEvent(new Event("change")); + } /** * @copy org.apache.royale.core.IBead#strand
