mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 09:12:30 +02:00
LCL: Prevent a design-time crash in TCheckComboBox. Issue #33889, patch from Vojtěch Čihák.
git-svn-id: trunk@58375 -
This commit is contained in:
parent
0141dd2967
commit
5c474d5f12
@ -284,6 +284,8 @@ type
|
||||
protected
|
||||
FCheckHighlight: Boolean;
|
||||
FCheckSize: TSize;
|
||||
FDropped: Boolean;
|
||||
FHilightedIndex: Integer;
|
||||
FHiLiteLeft: Integer;
|
||||
FHiLiteRight: Integer;
|
||||
FNeedMeasure: Boolean;
|
||||
@ -306,6 +308,7 @@ type
|
||||
procedure MouseLeave; override;
|
||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||
procedure SetItemHeight(const AValue: Integer); override;
|
||||
procedure SetItems(const Value: TStrings); override;
|
||||
procedure Select; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
|
@ -550,6 +550,7 @@ end;
|
||||
|
||||
procedure TCustomCheckCombo.CloseUp;
|
||||
begin
|
||||
FDropped:=False;
|
||||
if FRejectDropDown then
|
||||
begin
|
||||
FRejectDropDown:=False;
|
||||
@ -661,7 +662,10 @@ begin { do not call inherited ! }
|
||||
Canvas.Brush.Style:=bsClear;
|
||||
if (not (odSelected in State) or not aDropped) and not aFocusedEditableMainItemNoDD
|
||||
then Canvas.Font.Color:=clWindowText
|
||||
else Canvas.Font.Color:=clHighlightText;
|
||||
else begin
|
||||
Canvas.Font.Color:=clHighlightText;
|
||||
FHilightedIndex:=Index;
|
||||
end;
|
||||
if aFocusedEditableMainItemNoDD then
|
||||
begin
|
||||
LCLIntf.SetBkColor(Canvas.Handle, ColorToRGB(clBtnFace));
|
||||
@ -697,12 +701,13 @@ begin
|
||||
aRect:=Rect(FHiLiteLeft, 0, FHiLiteRight, Height);
|
||||
FRejectDropDown:=PtInRect(aRect, aCursorPos);
|
||||
{$ENDIF}
|
||||
FDropped:=True;
|
||||
if not FRejectDropDown then
|
||||
begin
|
||||
inherited DropDown;
|
||||
FRejectToggleOnSelect:=False;
|
||||
end else
|
||||
if ItemEnabled[ItemIndex] then Toggle(ItemIndex);
|
||||
if (ItemIndex>=0) and ItemEnabled[ItemIndex] then Toggle(ItemIndex);
|
||||
end;
|
||||
|
||||
procedure TCustomCheckCombo.FontChanged(Sender: TObject);
|
||||
@ -752,30 +757,20 @@ procedure TCustomCheckCombo.KeyDown(var Key: Word; Shift: TShiftState);
|
||||
begin
|
||||
case Key of
|
||||
VK_RETURN:
|
||||
begin
|
||||
if not DroppedDown then
|
||||
begin
|
||||
DroppedDown:=True;
|
||||
Key:=0;
|
||||
end else
|
||||
begin
|
||||
if (ItemIndex>=0) and ItemEnabled[ItemIndex] then
|
||||
begin
|
||||
Toggle(ItemIndex);
|
||||
Key:=0;
|
||||
DroppedDown:=False;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if FDropped then
|
||||
if (ItemIndex=FHilightedIndex) and ItemEnabled[ItemIndex] then Toggle(ItemIndex);
|
||||
VK_SPACE:
|
||||
begin
|
||||
if DroppedDown then
|
||||
if (ItemIndex>=0) and ItemEnabled[ItemIndex] then
|
||||
begin
|
||||
if ItemIndex<>FHilightedIndex then
|
||||
begin
|
||||
Toggle(ItemIndex);
|
||||
Key:=0;
|
||||
if DroppedDown then DroppedDown:=False;
|
||||
ItemIndex:=FHilightedIndex;
|
||||
inherited Select;
|
||||
end;
|
||||
end;
|
||||
Toggle(ItemIndex);
|
||||
DroppedDown:=False;
|
||||
end;
|
||||
end;
|
||||
inherited KeyDown(Key, Shift);
|
||||
end;
|
||||
@ -796,7 +791,7 @@ procedure TCustomCheckCombo.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||
var aHighlight: Boolean;
|
||||
begin
|
||||
inherited MouseMove(Shift, X, Y);
|
||||
aHighlight:= ((X>FHiLiteLeft) and (X<FHiLiteRight));
|
||||
aHighlight:=((X>FHiLiteLeft) and (X<FHiLiteRight));
|
||||
if aHighlight<>FCheckHighlight then
|
||||
begin
|
||||
FCheckHighlight:=aHighlight;
|
||||
@ -815,6 +810,7 @@ begin
|
||||
if ItemEnabled[ItemIndex] then Toggle(ItemIndex);
|
||||
FRejectToggleOnSelect:=True;
|
||||
end;
|
||||
FDropped:=False;
|
||||
end;
|
||||
|
||||
procedure TCustomCheckCombo.SetItemHeight(const AValue: Integer);
|
||||
@ -823,6 +819,13 @@ begin
|
||||
FNeedMeasure:=True;
|
||||
end;
|
||||
|
||||
procedure TCustomCheckCombo.SetItems(const Value: TStrings);
|
||||
begin
|
||||
ClearItemStates;
|
||||
inherited SetItems(Value);
|
||||
InitItemStates;
|
||||
end;
|
||||
|
||||
procedure TCustomCheckCombo.Toggle(AIndex: Integer);
|
||||
const caNewStateMap: array [TCheckBoxState, Boolean] of TCheckBoxState =
|
||||
{ False (AllowGrayed) True }
|
||||
@ -901,5 +904,3 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user