Added EndOfLineComplete capability for AutoCompleteText from Hwang Weng Sun

git-svn-id: trunk@8528 -
This commit is contained in:
mattias 2006-01-16 09:14:47 +00:00
parent 1bde0fc078
commit 126f596799
2 changed files with 16 additions and 5 deletions

View File

@ -435,7 +435,7 @@ var iSelStart: Integer;
sCompleteText: string;
begin
inherited KeyUp(Key, Shift);
if ((cbactEnabled in FAutoCompleteText) and (Style = csDropDown)) then
if ((cbactEnabled in FAutoCompleteText) and (Style <> csDropDownList)) then
begin
//Only happens with alpha-numeric keys and return key and csDropDown Style
if not (IsEditableTextKey(Key) or (Key = VK_RETURN)) then Exit;
@ -443,6 +443,8 @@ begin
SelectAll else
begin
iSelStart := SelStart;//Capture original cursor position
//End of line completion
if ((iSelStart < Length(Text)) and (cbactEndOfLineComplete in FAutoCompleteText)) then Exit;
sCompleteText := GetCompleteText(Text, iSelStart,
(cbactSearchCaseSensitive in FAutoCompleteText),
(cbactSearchAscending in FAutoCompleteText), Items);
@ -456,6 +458,13 @@ begin
end;//End if ((cbactEnabled in FAutoCompleteText) and (Style = csDropDown))
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;
@ -604,7 +613,7 @@ begin
ArrowKeysTraverseList := True;
TabStop := true;
ParentColor := false;
FAutoCompleteText := [cbactSearchAscending];
FAutoCompleteText := [cbactEndOfLineComplete, cbactSearchAscending];
end;
{------------------------------------------------------------------------------

View File

@ -212,9 +212,10 @@ type
{ TCustomComboBox }
TComboBoxAutoCompleteTextOption = (
cbactEnabled,
cbactSearchCaseSensitive,
cbactSearchAscending
cbactEnabled,//Enable Auto-Completion Feature
cbactEndOfLineComplete,//Perform Auto-Complete only when cursor is at end of line
cbactSearchCaseSensitive,//Search Text with CaseSensitivity
cbactSearchAscending//Search Text from top of the list
);
TComboBoxAutoCompleteText = set of TComboBoxAutoCompleteTextOption;
@ -300,6 +301,7 @@ type
procedure RealSetText(const AValue: TCaption); override;
procedure KeyDown(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;
property DropDownCount: Integer read FDropDownCount write SetDropDownCount default 8;