LCL: ColorBox - keep FSelected in sync all the time. fixes issue #22729

git-svn-id: trunk@38396 -
This commit is contained in:
zeljko 2012-08-27 08:57:04 +00:00
parent 9fbffd805b
commit d444ee76f9

View File

@ -376,8 +376,15 @@ begin
if HandleAllocated then if HandleAllocated then
begin begin
if ItemIndex <> -1 then if ItemIndex <> -1 then
Result := Colors[ItemIndex] begin
else Result := Colors[ItemIndex];
// keep FSelected in sync
if FSelected <> Result then
begin
// DebugLn('WARNING TCustomColorBox: FSelected out of sync with Colors[0]');
FSelected := Result;
end;
end else
Result := FSelected; Result := FSelected;
end end
else else
@ -432,7 +439,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomColorBox.SetSelected(Value: TColor); procedure TCustomColorBox.SetSelected(Value: TColor);
begin begin
if Selected = Value then if FSelected = Value then
Exit; Exit;
FSelected := Value; FSelected := Value;
@ -620,7 +627,7 @@ begin
if (cbCustomColor in Style) and (ItemIndex = 0) then // custom color has been selected if (cbCustomColor in Style) and (ItemIndex = 0) then // custom color has been selected
PickCustomColor; PickCustomColor;
if ItemIndex <> -1 then if ItemIndex <> -1 then
FSelected := Colors[ItemIndex]; Selected := Colors[ItemIndex];
inherited CloseUp; inherited CloseUp;
end; end;