You've already forked lazarus-ccr
ExCtrls: Fix CheckComboBoxEx not closing up when button is clicked in dropped-down state.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8145 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -52,7 +52,6 @@ begin
|
||||
FCombo := TCheckComboBoxEx.Create(self);
|
||||
FCombo.Align := alTop;
|
||||
FCombo.BorderSpacing.Around := 6;
|
||||
//FCombo.AutoDropDown := true;
|
||||
FCombo.Items.Add('Item 1');
|
||||
FCombo.Items.Add('Item 2');
|
||||
FCombo.Items.Add('Item 3');
|
||||
|
@ -66,6 +66,7 @@ type
|
||||
FAutoDropDown: Boolean;
|
||||
FButtonWidth: Integer;
|
||||
FCheckListBox: TCheckListBox;
|
||||
FCloseUpTime: TDateTime;
|
||||
FDelimiter: Char;
|
||||
FDropDownCount: Integer;
|
||||
FDropDownImageIndex: TCheckComboBoxExImageIndex;
|
||||
@ -82,6 +83,8 @@ type
|
||||
FOnDropDown: TNotifyEvent;
|
||||
FOnItemChange: TCheckItemChange;
|
||||
FOnItemClick: TCheckListClicked;
|
||||
procedure ButtonMouseDownHandler(Sender: TObject;
|
||||
AButton: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
procedure CheckComboBoxFormCloseHandler(Sender: TObject; var CloseAction: TCloseAction);
|
||||
function GetButtonWidth: Integer;
|
||||
function GetChecked(AIndex: Integer): Boolean;
|
||||
@ -108,6 +111,7 @@ type
|
||||
protected
|
||||
procedure ButtonClick; override;
|
||||
procedure CloseUp;
|
||||
function CreateBuddy: TControl; override;
|
||||
procedure CreateHandle; override;
|
||||
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||
const AXProportion, AYProportion: Double); override;
|
||||
@ -661,13 +665,24 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCheckComboBoxEx.ButtonClick;
|
||||
begin
|
||||
{
|
||||
if DroppedDown then
|
||||
CloseUp
|
||||
else
|
||||
ShowPopup;
|
||||
}
|
||||
end;
|
||||
|
||||
procedure TCheckComboBoxEx.ButtonMouseDownHandler(Sender: TObject;
|
||||
AButton: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
if DroppedDown then
|
||||
CloseUp
|
||||
else
|
||||
ShowPopup;
|
||||
end;
|
||||
|
||||
|
||||
procedure TCheckComboBoxEx.CheckAll(AState: TCheckBoxState;
|
||||
AAllowGrayed: Boolean = true; AAllowDisabled: Boolean = true);
|
||||
var
|
||||
@ -720,6 +735,13 @@ begin
|
||||
InvalidateButton;
|
||||
UpdateCaption;
|
||||
DoCloseUp;
|
||||
FCloseUpTime := Now();
|
||||
end;
|
||||
|
||||
function TCheckComboBoxEx.CreateBuddy: TControl;
|
||||
begin
|
||||
Result := inherited;
|
||||
TSpeedButton(Result).OnMouseDown := @ButtonMouseDownHandler;
|
||||
end;
|
||||
|
||||
procedure TCheckComboBoxEx.CreateHandle;
|
||||
@ -1041,6 +1063,9 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCheckComboBoxEx.ShowPopup;
|
||||
const
|
||||
MILLISECOND = 1.0/(24*60*60*100);
|
||||
DELAY = 10*MILLISECOND;
|
||||
var
|
||||
PopupOrigin: TPoint;
|
||||
PopupWidth: Integer;
|
||||
@ -1048,7 +1073,10 @@ var
|
||||
begin
|
||||
if FItems.Count = 0 then
|
||||
exit;
|
||||
|
||||
|
||||
if Now() - FCloseUpTime < DELAY then
|
||||
exit;
|
||||
|
||||
F := TCheckComboBoxForm.CreateNew(Application);
|
||||
F.FCaller := Self;
|
||||
F.BiDiMode := BiDiMode;
|
||||
|
Reference in New Issue
Block a user