cocoa: if closewindow button (red-x) is pressed, cancel color selection, instead of accepting the color

git-svn-id: trunk@62710 -
This commit is contained in:
dmitry 2020-03-08 05:33:20 +00:00
parent 45ac9380f3
commit 04ca721bfc

View File

@ -92,7 +92,7 @@ type
public public
colorPanel: NSColorPanel; colorPanel: NSColorPanel;
ColorDialog: TColorDialog; ColorDialog: TColorDialog;
DontPickColorOnClose: Boolean; didPickColor: Boolean;
// NSWindowDelegateProtocol // NSWindowDelegateProtocol
procedure windowWillClose(notification: NSNotification); message 'windowWillClose:'; procedure windowWillClose(notification: NSNotification); message 'windowWillClose:';
// //
@ -621,7 +621,7 @@ end;
procedure TColorPanelDelegate.windowWillClose(notification: NSNotification); procedure TColorPanelDelegate.windowWillClose(notification: NSNotification);
begin begin
if not DontPickColorOnClose then if didPickColor then
begin begin
ColorDialog.UserChoice := mrOk; ColorDialog.UserChoice := mrOk;
doPickColor(); doPickColor();
@ -637,15 +637,13 @@ end;
procedure TColorPanelDelegate.pickColor(); procedure TColorPanelDelegate.pickColor();
begin begin
ColorDialog.UserChoice := mrCancel; ColorDialog.UserChoice := mrCancel;
DontPickColorOnClose := True; didPickColor := True;
doPickColor(); doPickColor();
exit(); exit();
end; end;
procedure TColorPanelDelegate.exit(); procedure TColorPanelDelegate.exit();
begin begin
ColorDialog.UserChoice := mrOk;
DontPickColorOnClose := True;
colorPanel.close(); colorPanel.close();
end; end;