mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 20:39:23 +02:00
Added EndOfLineComplete capability for AutoCompleteText from Hwang Weng Sun
git-svn-id: trunk@8528 -
This commit is contained in:
parent
1bde0fc078
commit
126f596799
@ -435,7 +435,7 @@ var iSelStart: Integer;
|
|||||||
sCompleteText: string;
|
sCompleteText: string;
|
||||||
begin
|
begin
|
||||||
inherited KeyUp(Key, Shift);
|
inherited KeyUp(Key, Shift);
|
||||||
if ((cbactEnabled in FAutoCompleteText) and (Style = csDropDown)) then
|
if ((cbactEnabled in FAutoCompleteText) and (Style <> csDropDownList)) then
|
||||||
begin
|
begin
|
||||||
//Only happens with alpha-numeric keys and return key and csDropDown Style
|
//Only happens with alpha-numeric keys and return key and csDropDown Style
|
||||||
if not (IsEditableTextKey(Key) or (Key = VK_RETURN)) then Exit;
|
if not (IsEditableTextKey(Key) or (Key = VK_RETURN)) then Exit;
|
||||||
@ -443,6 +443,8 @@ begin
|
|||||||
SelectAll else
|
SelectAll else
|
||||||
begin
|
begin
|
||||||
iSelStart := SelStart;//Capture original cursor position
|
iSelStart := SelStart;//Capture original cursor position
|
||||||
|
//End of line completion
|
||||||
|
if ((iSelStart < Length(Text)) and (cbactEndOfLineComplete in FAutoCompleteText)) then Exit;
|
||||||
sCompleteText := GetCompleteText(Text, iSelStart,
|
sCompleteText := GetCompleteText(Text, iSelStart,
|
||||||
(cbactSearchCaseSensitive in FAutoCompleteText),
|
(cbactSearchCaseSensitive in FAutoCompleteText),
|
||||||
(cbactSearchAscending in FAutoCompleteText), Items);
|
(cbactSearchAscending in FAutoCompleteText), Items);
|
||||||
@ -456,6 +458,13 @@ begin
|
|||||||
end;//End if ((cbactEnabled in FAutoCompleteText) and (Style = csDropDown))
|
end;//End if ((cbactEnabled in FAutoCompleteText) and (Style = csDropDown))
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomComboBox.MouseUp(Button: TMouseButton; Shift:TShiftState; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
inherited MouseUp(Button, Shift, X, Y);
|
||||||
|
if (Style = csDropDownList) then
|
||||||
|
DroppedDown := not DroppedDown;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
function TCustomComboBox.SelectItem(const AnItem: String): Boolean;
|
function TCustomComboBox.SelectItem(const AnItem: String): Boolean;
|
||||||
|
|
||||||
@ -604,7 +613,7 @@ begin
|
|||||||
ArrowKeysTraverseList := True;
|
ArrowKeysTraverseList := True;
|
||||||
TabStop := true;
|
TabStop := true;
|
||||||
ParentColor := false;
|
ParentColor := false;
|
||||||
FAutoCompleteText := [cbactSearchAscending];
|
FAutoCompleteText := [cbactEndOfLineComplete, cbactSearchAscending];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
@ -212,9 +212,10 @@ type
|
|||||||
|
|
||||||
{ TCustomComboBox }
|
{ TCustomComboBox }
|
||||||
TComboBoxAutoCompleteTextOption = (
|
TComboBoxAutoCompleteTextOption = (
|
||||||
cbactEnabled,
|
cbactEnabled,//Enable Auto-Completion Feature
|
||||||
cbactSearchCaseSensitive,
|
cbactEndOfLineComplete,//Perform Auto-Complete only when cursor is at end of line
|
||||||
cbactSearchAscending
|
cbactSearchCaseSensitive,//Search Text with CaseSensitivity
|
||||||
|
cbactSearchAscending//Search Text from top of the list
|
||||||
);
|
);
|
||||||
TComboBoxAutoCompleteText = set of TComboBoxAutoCompleteTextOption;
|
TComboBoxAutoCompleteText = set of TComboBoxAutoCompleteTextOption;
|
||||||
|
|
||||||
@ -300,6 +301,7 @@ type
|
|||||||
procedure RealSetText(const AValue: TCaption); override;
|
procedure RealSetText(const AValue: TCaption); override;
|
||||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
||||||
|
procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X, Y: Integer); override;
|
||||||
function SelectItem(const AnItem: String): Boolean;
|
function SelectItem(const AnItem: String): Boolean;
|
||||||
|
|
||||||
property DropDownCount: Integer read FDropDownCount write SetDropDownCount default 8;
|
property DropDownCount: Integer read FDropDownCount write SetDropDownCount default 8;
|
||||||
|
Loading…
Reference in New Issue
Block a user