You've already forked lazarus-ccr
mbColorLib: Add locking mechanism for OnChange events. Fix OfficeDlg forgetting selected color if picker type is changed on custom page.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5599 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -17,6 +17,7 @@ type
|
||||
private
|
||||
FOnChange: TNotifyEvent;
|
||||
FOnGetHintStr: TGetHintStrEvent;
|
||||
FLockChange: Integer;
|
||||
protected
|
||||
FBufferBmp: TBitmap;
|
||||
FGradientWidth: Integer;
|
||||
@@ -46,6 +47,9 @@ type
|
||||
function GetColorAtPoint(X, Y: Integer): TColor; virtual;
|
||||
function GetHexColorAtPoint(X, Y: integer): string;
|
||||
function GetHexColorUnderCursor: string; virtual;
|
||||
procedure Lock;
|
||||
function IsLocked: Boolean;
|
||||
procedure Unlock;
|
||||
published
|
||||
property ParentColor default true;
|
||||
property SelectedColor: TColor read GetSelectedColor write SetSelectedColor;
|
||||
@@ -115,7 +119,7 @@ end;
|
||||
|
||||
procedure TmbBasicPicker.DoChange;
|
||||
begin
|
||||
if Assigned(FOnChange) then
|
||||
if (FLockChange = 0) and Assigned(FOnChange) and (ComponentState = []) then
|
||||
FOnChange(self);
|
||||
end;
|
||||
|
||||
@@ -164,6 +168,16 @@ begin
|
||||
FOnGetHintStr(Self, X, Y, Result);
|
||||
end;
|
||||
|
||||
function TmbBasicPicker.IsLocked: Boolean;
|
||||
begin
|
||||
Result := FLockChange > 0;
|
||||
end;
|
||||
|
||||
procedure TmbBasicPicker.Lock;
|
||||
begin
|
||||
inc(FLockChange);
|
||||
end;
|
||||
|
||||
procedure TmbBasicPicker.PaintParentBack;
|
||||
begin
|
||||
PaintParentBack(Canvas);
|
||||
@@ -209,5 +223,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TmbBasicPicker.Unlock;
|
||||
begin
|
||||
dec(FLockChange);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Reference in New Issue
Block a user