From 05ac260de87d87cbcc37b526bb6aee791ffec6cc Mon Sep 17 00:00:00 2001 From: Robert Chiquini Date: Fri, 23 Jun 2017 06:23:16 -0700 Subject: [PATCH] Clear previews before returning results from HSVColorPicker UIs This patch fixes a bug where previewed operations that were not properly cleaned up upon confirming a color in HSVColorPicker UIs affected history tracking. Signed-off-by: Robert Chiquini --- Components/HSVColorPicker.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Components/HSVColorPicker.lua b/Components/HSVColorPicker.lua index 4c27e89..b6aac80 100644 --- a/Components/HSVColorPicker.lua +++ b/Components/HSVColorPicker.lua @@ -40,8 +40,23 @@ function Component.Start(InitialColor, Callback, SelectionPreventionCallback, Pr Connections.TrackBrightness = Support.AddGuiInputListener(View.Brightness, 'Began', 'MouseButton1', true, Support.Call(StartTrackingMouse, 'B')); Connections.StopTrackingMouse = Support.AddUserInputListener('Ended', 'MouseButton1', true, StopTrackingMouse); - -- Connect OK/Cancel buttons - Cheer.Bind(View.OkButton, { function () View:Destroy(); return Color3.fromHSV(#Hue, #Saturation, #Brightness) end }, Callback); + -- Connect OK button to finish color picking + Cheer.Bind(View.OkButton, function () + + -- Clear any preview + if PreviewCallback then + PreviewCallback(); + end; + + -- Remove the UI + View:Destroy(); + + -- Return the selected color + Callback(Color3.fromHSV(#Hue, #Saturation, #Brightness)); + + end); + + -- Connect cancel button to clear preview and remove UI Cheer.Bind(View.CancelButton, function () if PreviewCallback then PreviewCallback() end; View:Destroy(); end); -- Store reference to callbacks