Skip to content

Commit

Permalink
Clear previews before returning results from HSVColorPicker UIs
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
GigsD4X committed Jun 23, 2017
1 parent d526c53 commit 05ac260
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Components/HSVColorPicker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 05ac260

Please sign in to comment.