mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-22 15:29:35 +01: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
|
protected
|
||||||
FCheckHighlight: Boolean;
|
FCheckHighlight: Boolean;
|
||||||
FCheckSize: TSize;
|
FCheckSize: TSize;
|
||||||
|
FDropped: Boolean;
|
||||||
|
FHilightedIndex: Integer;
|
||||||
FHiLiteLeft: Integer;
|
FHiLiteLeft: Integer;
|
||||||
FHiLiteRight: Integer;
|
FHiLiteRight: Integer;
|
||||||
FNeedMeasure: Boolean;
|
FNeedMeasure: Boolean;
|
||||||
@ -306,6 +308,7 @@ type
|
|||||||
procedure MouseLeave; override;
|
procedure MouseLeave; override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure SetItemHeight(const AValue: Integer); override;
|
procedure SetItemHeight(const AValue: Integer); override;
|
||||||
|
procedure SetItems(const Value: TStrings); override;
|
||||||
procedure Select; override;
|
procedure Select; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
|||||||
@ -550,6 +550,7 @@ end;
|
|||||||
|
|
||||||
procedure TCustomCheckCombo.CloseUp;
|
procedure TCustomCheckCombo.CloseUp;
|
||||||
begin
|
begin
|
||||||
|
FDropped:=False;
|
||||||
if FRejectDropDown then
|
if FRejectDropDown then
|
||||||
begin
|
begin
|
||||||
FRejectDropDown:=False;
|
FRejectDropDown:=False;
|
||||||
@ -661,7 +662,10 @@ begin { do not call inherited ! }
|
|||||||
Canvas.Brush.Style:=bsClear;
|
Canvas.Brush.Style:=bsClear;
|
||||||
if (not (odSelected in State) or not aDropped) and not aFocusedEditableMainItemNoDD
|
if (not (odSelected in State) or not aDropped) and not aFocusedEditableMainItemNoDD
|
||||||
then Canvas.Font.Color:=clWindowText
|
then Canvas.Font.Color:=clWindowText
|
||||||
else Canvas.Font.Color:=clHighlightText;
|
else begin
|
||||||
|
Canvas.Font.Color:=clHighlightText;
|
||||||
|
FHilightedIndex:=Index;
|
||||||
|
end;
|
||||||
if aFocusedEditableMainItemNoDD then
|
if aFocusedEditableMainItemNoDD then
|
||||||
begin
|
begin
|
||||||
LCLIntf.SetBkColor(Canvas.Handle, ColorToRGB(clBtnFace));
|
LCLIntf.SetBkColor(Canvas.Handle, ColorToRGB(clBtnFace));
|
||||||
@ -697,12 +701,13 @@ begin
|
|||||||
aRect:=Rect(FHiLiteLeft, 0, FHiLiteRight, Height);
|
aRect:=Rect(FHiLiteLeft, 0, FHiLiteRight, Height);
|
||||||
FRejectDropDown:=PtInRect(aRect, aCursorPos);
|
FRejectDropDown:=PtInRect(aRect, aCursorPos);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
FDropped:=True;
|
||||||
if not FRejectDropDown then
|
if not FRejectDropDown then
|
||||||
begin
|
begin
|
||||||
inherited DropDown;
|
inherited DropDown;
|
||||||
FRejectToggleOnSelect:=False;
|
FRejectToggleOnSelect:=False;
|
||||||
end else
|
end else
|
||||||
if ItemEnabled[ItemIndex] then Toggle(ItemIndex);
|
if (ItemIndex>=0) and ItemEnabled[ItemIndex] then Toggle(ItemIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCheckCombo.FontChanged(Sender: TObject);
|
procedure TCustomCheckCombo.FontChanged(Sender: TObject);
|
||||||
@ -752,30 +757,20 @@ procedure TCustomCheckCombo.KeyDown(var Key: Word; Shift: TShiftState);
|
|||||||
begin
|
begin
|
||||||
case Key of
|
case Key of
|
||||||
VK_RETURN:
|
VK_RETURN:
|
||||||
begin
|
if FDropped then
|
||||||
if not DroppedDown then
|
if (ItemIndex=FHilightedIndex) and ItemEnabled[ItemIndex] then Toggle(ItemIndex);
|
||||||
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;
|
|
||||||
VK_SPACE:
|
VK_SPACE:
|
||||||
begin
|
if DroppedDown then
|
||||||
if (ItemIndex>=0) and ItemEnabled[ItemIndex] then
|
if (ItemIndex>=0) and ItemEnabled[ItemIndex] then
|
||||||
|
begin
|
||||||
|
if ItemIndex<>FHilightedIndex then
|
||||||
begin
|
begin
|
||||||
Toggle(ItemIndex);
|
ItemIndex:=FHilightedIndex;
|
||||||
Key:=0;
|
inherited Select;
|
||||||
if DroppedDown then DroppedDown:=False;
|
|
||||||
end;
|
end;
|
||||||
end;
|
Toggle(ItemIndex);
|
||||||
|
DroppedDown:=False;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
inherited KeyDown(Key, Shift);
|
inherited KeyDown(Key, Shift);
|
||||||
end;
|
end;
|
||||||
@ -796,7 +791,7 @@ procedure TCustomCheckCombo.MouseMove(Shift: TShiftState; X, Y: Integer);
|
|||||||
var aHighlight: Boolean;
|
var aHighlight: Boolean;
|
||||||
begin
|
begin
|
||||||
inherited MouseMove(Shift, X, Y);
|
inherited MouseMove(Shift, X, Y);
|
||||||
aHighlight:= ((X>FHiLiteLeft) and (X<FHiLiteRight));
|
aHighlight:=((X>FHiLiteLeft) and (X<FHiLiteRight));
|
||||||
if aHighlight<>FCheckHighlight then
|
if aHighlight<>FCheckHighlight then
|
||||||
begin
|
begin
|
||||||
FCheckHighlight:=aHighlight;
|
FCheckHighlight:=aHighlight;
|
||||||
@ -815,6 +810,7 @@ begin
|
|||||||
if ItemEnabled[ItemIndex] then Toggle(ItemIndex);
|
if ItemEnabled[ItemIndex] then Toggle(ItemIndex);
|
||||||
FRejectToggleOnSelect:=True;
|
FRejectToggleOnSelect:=True;
|
||||||
end;
|
end;
|
||||||
|
FDropped:=False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCheckCombo.SetItemHeight(const AValue: Integer);
|
procedure TCustomCheckCombo.SetItemHeight(const AValue: Integer);
|
||||||
@ -823,6 +819,13 @@ begin
|
|||||||
FNeedMeasure:=True;
|
FNeedMeasure:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomCheckCombo.SetItems(const Value: TStrings);
|
||||||
|
begin
|
||||||
|
ClearItemStates;
|
||||||
|
inherited SetItems(Value);
|
||||||
|
InitItemStates;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomCheckCombo.Toggle(AIndex: Integer);
|
procedure TCustomCheckCombo.Toggle(AIndex: Integer);
|
||||||
const caNewStateMap: array [TCheckBoxState, Boolean] of TCheckBoxState =
|
const caNewStateMap: array [TCheckBoxState, Boolean] of TCheckBoxState =
|
||||||
{ False (AllowGrayed) True }
|
{ False (AllowGrayed) True }
|
||||||
@ -901,5 +904,3 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user