diff --git a/docs/xml/lcl/stdctrls.xml b/docs/xml/lcl/stdctrls.xml
index e5ae27d63c..e35f33d1be 100644
--- a/docs/xml/lcl/stdctrls.xml
+++ b/docs/xml/lcl/stdctrls.xml
@@ -1027,10 +1027,48 @@ radio buttons will be mutually exclusive within the group.
-
+
+ property AutoCompleteText: TComboBoxAutoCompleteText
+
+
+ TComboBoxAutoCompleteTextOption defines the behavior of the AutoComplete feature in a combobox control.
+ TComboBoxAutoCompleteTextOption = (cbactEnabled, cbactEndOfLineComplete, cbactRetainPrefixCase,
+ cbactSearchCaseSensitive, cbactSearchAscending);
+
+Defines the behavior of the AutoComplete feature.
+<ul><li>cbactEnabled: Enable Auto-Completion feature.</li><li>cbactEndOfLineComplete: Perform Auto-Complete only when cursor is at the end of the string.</li><li>cbactRetainPrefixCase: Retains the case of characters user has typed. (This option has no effect if cbactEndOfLineComplete is False)</li><li>cbactSearchCaseSensitive: Search completion string with case sensitivity.</li><li>cbactSearchAscending: Search completion string in accending order. (False will search in descending order)</li></ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TComboBoxAutoCompleteText = set of TComboBoxAutoCompleteTextOption;
+
+ <link id="TComboBoxAutoCompleteTextOption"/>
+
+
ComboBox Style
ComboBox Style: may be Simple, a Drop-Down or a drop-down list, or some version drawn by the Owner
@@ -1107,6 +1145,43 @@ radio buttons will be mutually exclusive within the group.
Custom Combination Box: the base class from which Combo Box is derived.
+
+ FCharCase: TEditCharCase
+
+
+
+
+
+ FAutoCompleteText: TComboBoxAutoCompleteText
+ Private variable of property AutoCompleteText.
+
+Options for behavior of the Auto-Complete feature.
+
+
+
+
+
+ FAutoSelect: Boolean
+ Private variable for property AutoSelect.
+
+When True, the edit control will select all its text when:
+<ul><li>It recieves focus</li><li>The Enter key is pressed.</li><li>A new item is selected.</li></ul>
+
+
+
+
+ FAutoSelected: Boolean
+ Private variable for property AutoSelected.
+
+True indicate that the edit or combobox control has just performed
+an AutoSelect opertation so that subsequent mouse-clicks and keystrokes
+proceeds normally without selecting the text.
+
+False is set when the edit or combobox control looses focus.
+
+
+
+
@@ -1187,7 +1262,11 @@ radio buttons will be mutually exclusive within the group.
-
+
+ Combo Box
+ Combo box. A simple combination of text box for free text entry, and a drop-down list allowing one of several options to be chosen.
+
+
@@ -1782,6 +1861,12 @@ radio buttons will be mutually exclusive within the group.
+
+ property CharCase: TEditCharCase
+ Indicates how text is displayed in a text editing control in the following ways:
+<ul><li>Normal case letters</li><li>Upper case letters</li><li>Lower case letters</li></ul>
+
+
@@ -1811,12 +1896,43 @@ radio buttons will be mutually exclusive within the group.
+
+
+
+
+
+
+
+ property AutoCompleteText: TComboBoxAutoCompleteText
+ Options for behavior of the Auto-Complete feature.
+
+ <link id="TComboBoxAutoCompleteTextOption"/>
+
+
+
+ property AutoSelect: Boolean
+ When True, the edit control will select all its text when:
+<ul><li>It recieves focus</li><li>The Enter key is pressed.</li><li>A new item is selected.</li></ul>
+
+
+
+
+ property AutoSelected: Boolean
+ True indicate that the edit or combobox control has just performed
+an AutoSelect operation so that subsequent mouse-clicks and keystrokes
+proceeds normally without selecting the text.
+
+False is set when the edit or combobox control looses focus.
+
+
+
+
@@ -1906,18 +2022,48 @@ radio buttons will be mutually exclusive within the group.
+
+ property AutoComplete: Boolean
+ True: Turns on auto-complete feature.
+False: Turns off auto-complete feature.
+
+
+
+
+ property AutoCompleteText: TComboBoxAutoCompleteText
+ Options for behavior of the Auto-Complete feature.
+
+ <link id="TComboBoxAutoCompleteTextOption"/>
+<link id="TComboBoxAutoCompleteText"/>
+
+
+
+
+ property AutoSelected: Boolean
+ When True, the edit control will select all its text when:
+<ul><li>It recieves focus</li><li>The Enter key is pressed.</li><li>A new item is selected.</li></ul>
+
+
+
+
+ property CharCase: TEditCharCase
+ Indicates how text is displayed in a text editing control in the following ways:
+<ul><li>Normal case letters</li><li>Upper case letters</li><li>Lower case letters</li></ul>
+
+
+
@@ -2095,7 +2241,11 @@ radio buttons will be mutually exclusive within the group.
-
+
+ Options for behavior of the Auto-Complete feature.
+
+ <link id="TComboBoxAutoCompleteTextOption"/><link id="TComboBoxAutoCompleteText"/>
+
@@ -3259,25 +3409,25 @@ radio buttons will be mutually exclusive within the group.
-
+ Determines the case of text displayed in the edit box or combobox.
-
+ Character case according to what the user types.
-
+ Converts every character that the user types into upper case characters.
-
+ Converts every character that the user types into lower case characters.
-
+ TEchoMode: Determines how strings in the edit box is displayed.
@@ -3298,11 +3448,34 @@ radio buttons will be mutually exclusive within the group.
Custom Edit
Custom Edit: the base type from which Edit Box is derived.
+
+ FAutoSelect: Boolean
+ Private variable for property AutoSelect.
+
+When True, the edit control will select all its text when:
+<ul><li>It recieves focus</li><li>The Enter key is pressed.</li><li>A new item is selected.</li></ul>
+
+
+
+
+ FAutoSelected: Boolean
+ Private variable for property AutoSelected.
+
+True indicate that the edit or combobox control has just performed
+an AutoSelect opertation so that subsequent mouse-clicks and keystrokes
+proceeds normally without selecting the text.
+
+False is set when the edit or combobox control looses focus.
+
+
-
-
-
+ FCharCase: TEditCharCase
+ Private variable for property CharCase.
+
+Indicates how text is displayed in a text editing control in the following ways:
+<ul><li>Normal case letters</li><li>Upper case letters</li><li>Lower case letters</li></ul>
+ <link id="TEditCharCase"/><link id="TEditCharCase.ecNormal"/><link id="TEditCharCase.ecUppercase"/><link id="TEditCharCase.ecLowerCase"/>
@@ -3583,6 +3756,25 @@ radio buttons will be mutually exclusive within the group.
+
+
+ property AutoSelect: Boolean
+ When True, the edit control will select all its text when it
+recieves focus or when the Enter key is pressed.
+
+
+
+
+
+ property AutoSelected: Boolean
+ True indicate that the edit or combobox control has just performed
+an AutoSelect operation so that subsequent mouse-clicks and keystrokes
+proceeds normally without selecting the text.
+
+False is set when the edit or combobox control looses focus.
+
+
+
@@ -3631,8 +3823,9 @@ radio buttons will be mutually exclusive within the group.
-
-
+ property CharCase: TEditCharCase
+ Indicates how text is displayed in a text editing control in the following ways:
+<ul><li>Normal case letters</li><li>Upper case letters</li><li>Lower case letters</li></ul>
@@ -3984,6 +4177,12 @@ radio buttons will be mutually exclusive within the group.
Edit Box: for entry or display of a single line of text.
Inherits most of its properties from TCustomEdit
+
+
+ property AutoSelected: Boolean
+
+
+
Action
@@ -4006,6 +4205,12 @@ radio buttons will be mutually exclusive within the group.
+
+ property AutoSelect: Boolean
+
+
+
+
@@ -5686,8 +5891,15 @@ User-defined Procedure
-
-
+ FAutoSelected: Boolean
+ Private variable for property AutoSelected.
+
+True indicate that the edit or combobox control has just performed
+an AutoSelect operation so that subsequent mouse-clicks and keystrokes
+proceeds normally without selecting the text.
+
+False is set when the edit or combobox control looses focus.
+
diff --git a/lcl/include/customcombobox.inc b/lcl/include/customcombobox.inc
index 51083c5604..86ff8a8c94 100644
--- a/lcl/include/customcombobox.inc
+++ b/lcl/include/customcombobox.inc
@@ -101,6 +101,24 @@ begin
end;
end;
+procedure TCustomComboBox.DoEnter;
+begin
+ inherited DoEnter;
+ //AutoSelect when DoEnter is fired by keyboard
+ if (Style = csDropDownList) then Exit;//Non editable style
+ if (FAutoSelect and not (csLButtonDown in ControlState)) then
+ begin
+ SelectAll;
+ if (SelText = Text) then FAutoSelected := True;
+ end;//End if (((Style = csDropDown) or.........
+end;
+
+procedure TCustomComboBox.DoExit;
+begin
+ FAutoSelected := False;
+ inherited DoExit;
+end;
+
{------------------------------------------------------------------------------
Method: TCustomComboBox.SetSorted
Params: val - true means "sort" the combo
@@ -204,6 +222,11 @@ begin
if not ReadOnly then
EditingDone;
if Assigned(FOnCloseUp) then FOnCloseUp(Self);
+ if FAutoSelect then
+ begin
+ SelectAll;
+ if (SelText = Text) then FAutoSelected := True;
+ end;//End if FAutoSelect
end;
{------------------------------------------------------------------------------
@@ -376,6 +399,18 @@ begin
inherited WMChar(Message);
end;
+procedure TCustomComboBox.SetCharCase(eccCharCase: TEditCharCase);
+begin
+ if (FCharCase <> eccCharCase) then
+ begin
+ FCharCase := eccCharCase;
+ case FCharCase of
+ ecUpperCase: Text := UpperCase(Text);
+ ecLowerCase: Text := Lowercase(Text);
+ end;//End case
+ end;//End if (FCharCase <> eccCharCase)
+end;
+
procedure TCustomComboBox.KeyDown(var Key: Word; Shift: TShiftState);
var
skip : Boolean;
@@ -427,39 +462,69 @@ begin
inherited KeyUp(Key, Shift);
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) or (ssShift in Shift)) then Exit;
- if (Key = VK_RETURN) then
- SelectAll else
+ //Only happens with alpha-numeric keys and return key and editable Style
+ if (IsEditableTextKey(Key) or (Key = VK_RETURN) or (ssShift in Shift)) then
begin
- iSelStart := SelStart;//Capture original cursor position
- //End of line completion
- if ((iSelStart < Length(Text)) and (cbactEndOfLineComplete in FAutoCompleteText)) then Exit;
- sPrefixText := LeftStr(Text, iSelStart);
- sCompleteText := GetCompleteText(Text, iSelStart,
- (cbactSearchCaseSensitive in FAutoCompleteText),
- (cbactSearchAscending in FAutoCompleteText), Items);
- if not (sCompleteText = Text) then
+ if (Key = VK_RETURN) then
+ SelectAll else
begin
- sResultText := sCompleteText;
- if ((cbactEndOfLineComplete in FAutoCompleteText) and
- (cbactRetainPrefixCase in FAutoCompleteText)) then
- begin//Retain Prefix Character cases
- Delete(sResultText, 1, iSelStart);
- Insert(sPrefixText, sResultText, 1);
- end;//End if ((cbactEndOfLineComplete in FAutoCompleteText) and....
- Text := sResultText;
- SelStart := iSelStart;
- SelLength := Length(Text);
- end;//End if not (sCompleteText = Text)
- end;//End if (Key = VK_RETURN)
+ iSelStart := SelStart;//Capture original cursor position
+ //End of line completion
+ if ((iSelStart < Length(Text)) and (cbactEndOfLineComplete in FAutoCompleteText)) then Exit;
+ sPrefixText := LeftStr(Text, iSelStart);
+ sCompleteText := GetCompleteText(Text, iSelStart,
+ (cbactSearchCaseSensitive in FAutoCompleteText),
+ (cbactSearchAscending in FAutoCompleteText), Items);
+ if not (sCompleteText = Text) then
+ begin
+ sResultText := sCompleteText;
+ if ((cbactEndOfLineComplete in FAutoCompleteText) and
+ (cbactRetainPrefixCase in FAutoCompleteText)) then
+ begin//Retain Prefix Character cases
+ Delete(sResultText, 1, iSelStart);
+ Insert(sPrefixText, sResultText, 1);
+ end;//End if ((cbactEndOfLineComplete in FAutoCompleteText) and....
+ Text := sResultText;
+ SelStart := iSelStart;
+ SelLength := Length(Text);
+ end;//End if not (sCompleteText = Text)
+ end;//End if (Key = VK_RETURN)
+ end;//End if (IsEditableTextKey(Key) or (Key = VK_RETURN) or (ssShift in Shift))
end;//End if ((cbactEnabled in FAutoCompleteText) and (Style = csDropDown))
+ //SelectAll when hitting return key for AutoSelect feature
+ if (Key = VK_RETURN) then
+ begin
+ if FAutoSelect then
+ begin
+ SelectAll;
+ if (SelText = Text) then FAutoSelected := True;
+ end;//End if FAutoSelect
+ end;//End if (Key = VK_RETURN)
+end;
+
+procedure TCustomComboBox.KeyPress(var Key: char);
+begin
+ //Convert character cases if FCharCase is not ecNormalCase
+ case FCharCase of
+ ecLowerCase: Key := lowerCase(Key);
+ ecUpperCase: Key := upCase(Key);
+ end;//End case
+ inherited KeyPress(Key);
end;
procedure TCustomComboBox.MouseUp(Button: TMouseButton; Shift:TShiftState;
X, Y: Integer);
begin
- inherited MouseUp(Button, Shift, X, Y);
+ inherited MouseUp(Button, Shift, X, Y);
+ //AutoSelect when left mouse is clicked for the 1st time after having focus
+ if (Button = mbLeft) then
+ begin
+ if (FAutoSelect and not FAutoSelected) then
+ begin
+ SelectAll;
+ if (SelText = Text) then FAutoSelected := True;
+ end;//End if (FAutoSelect and not FAutoSelected)
+ end;//End if (Button = mbLeft)
//if (Style = csDropDownList) then
// DroppedDown := not DroppedDown;
end;
@@ -627,6 +692,9 @@ begin
TabStop := true;
ParentColor := false;
FAutoCompleteText := [cbactEndOfLineComplete, cbactSearchAscending];
+ FAutoSelect := False;
+ FAutoSelected := False;
+ FCharCase := ecNormal;
end;
{------------------------------------------------------------------------------
diff --git a/lcl/include/customedit.inc b/lcl/include/customedit.inc
index 38f47bc638..7ad3e6b2c7 100644
--- a/lcl/include/customedit.inc
+++ b/lcl/include/customedit.inc
@@ -55,6 +55,8 @@ begin
SetInitialBounds(0,0,80,23);
FEchoMode := emNormal;
BorderStyle := bsSingle;
+ FAutoSelect := False;
+ FAutoSelected := False;
end;
{------------------------------------------------------------------------------
@@ -348,7 +350,15 @@ end;
procedure TCustomEdit.KeyUp(var Key: Word; Shift: TShiftState);
begin
inherited KeyUp(Key, Shift);
- if Key=VK_RETURN then EditingDone;
+ if Key=VK_RETURN then
+ begin
+ EditingDone;
+ if FAutoSelect then
+ begin
+ SelectAll;
+ if (SelText = Text) then FAutoSelected := True;
+ end;//End if FAutoSelect
+ end;//End if Key=VK_RETURN
end;
procedure TCustomEdit.WMChar(var Message: TLMChar);
@@ -363,6 +373,20 @@ begin
inherited WMChar(Message);
end;
+procedure TCustomEdit.MouseUp(Button: TMouseButton; Shift:TShiftState; X, Y: Integer);
+begin
+ inherited MouseUp(Button, Shift, X, Y);
+ //AutoSelect when left mouse is clicked for the 1st time after having focus
+ if (Button = mbLeft) then
+ begin
+ if (FAutoSelect and not FAutoSelected) then
+ begin
+ SelectAll;
+ if (SelText = Text) then FAutoSelected := True;
+ end;//End if (FAutoSelect and not FAutoSelected)
+ end;//End if (Button = mbLeft)
+end;
+
{------------------------------------------------------------------------------
Method: TCustomEdit.SetModified
Params: Value to set FModified to
@@ -396,6 +420,23 @@ Begin
if Assigned(FOnChange) then FOnChange(Self);
end;
+procedure TCustomEdit.DoEnter;
+begin
+ //AutoSelect when DoEnter is fired by keyboard
+ if (FAutoSelect and not (csLButtonDown in ControlState)) then
+ begin
+ SelectAll;
+ if (SelText = Text) then FAutoSelected := True;
+ end;//End if FAutoSelect
+ inherited DoEnter;
+end;
+
+procedure TCustomEdit.DoExit;
+begin
+ FAutoSelected := False;
+ inherited DoExit;
+end;
+
procedure TCustomEdit.InitializeWnd;
var
ASelStart, ASelLength : integer;
diff --git a/lcl/stdctrls.pp b/lcl/stdctrls.pp
index e5d1b2e28a..b5cdae89a6 100644
--- a/lcl/stdctrls.pp
+++ b/lcl/stdctrls.pp
@@ -36,6 +36,11 @@ uses
type
+ { TCustomEdit Options}
+
+ TEditCharCase = (ecNormal, ecUppercase, ecLowerCase);
+ TEchoMode = (emNormal, emNone, emPassword);
+
{ TScrollBar }
TScrollStyle = (ssNone, ssHorizontal, ssVertical, ssBoth,
@@ -238,7 +243,10 @@ type
TCustomComboBox = class(TWinControl)
private
+ FCharCase: TEditCharCase;
FAutoCompleteText: TComboBoxAutoCompleteText;
+ FAutoSelect: Boolean;
+ FAutoSelected: Boolean;
FAutoDropDown: Boolean;
FCanvas: TCanvas;
FDropDownCount: Integer;
@@ -275,9 +283,12 @@ type
procedure UpdateSorted;
procedure SetArrowKeysTraverseList(Value: Boolean);
procedure WMChar(var Message: TLMChar); message LM_CHAR;
+ procedure SetCharCase(eccCharCase: TEditCharCase);
protected
procedure InitializeWnd; override;
procedure DestroyWnd; override;
+ procedure DoEnter; override;
+ procedure DoExit; override;
procedure DrawItem(Index: Integer; ARect: TRect;
State: TOwnerDrawState); virtual;
procedure LMChanged(var Msg); message LM_CHANGED;
@@ -308,6 +319,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 KeyPress(var Key: char); override;
procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X, Y: Integer); override;
function SelectItem(const AnItem: String): Boolean;
@@ -333,6 +345,7 @@ type
MaxHistoryCount: integer; SetAsText, CaseSensitive: boolean);
procedure Clear; virtual;
procedure ClearSelection; //override;
+ property CharCase: TEditCharCase read FCharCase write SetCharCase;
property DroppedDown: Boolean read GetDroppedDown write SetDroppedDown;
procedure MeasureItem(Index: Integer; var TheHeight: Integer); virtual;
procedure SelectAll;
@@ -341,6 +354,8 @@ type
read FAutoCompleteText write FAutoCompleteText;
property AutoDropDown: Boolean
read FAutoDropDown write FAutoDropDown default False;
+ property AutoSelect: Boolean read FAutoSelect write FAutoSelect default False;
+ property AutoSelected: Boolean read FAutoSelected write FAutoSelected;
property ArrowKeysTraverseList: Boolean read FArrowKeysTraverseList
write SetArrowKeysTraverseList default True;
property Canvas: TCanvas read FCanvas;
@@ -367,7 +382,9 @@ type
property AutoComplete;
property AutoCompleteText;
property AutoDropDown;
+ property AutoSelect;
property BorderSpacing;
+ property CharCase;
property Ctl3D;
property DropDownCount;
property Enabled;
@@ -548,6 +565,8 @@ type
property ClickOnSelChange;
property Color;
property Constraints;
+ property DragCursor;
+ property DragMode;
property ExtendedSelect;
property Enabled;
property Font;
@@ -588,15 +607,12 @@ type
end;
- { TCustomEdit }
-
- TEditCharCase = (ecNormal, ecUppercase, ecLowerCase);
- TEchoMode = (emNormal, emNone, emPassword);
-
{ TCustomEdit }
TCustomEdit = class(TWinControl)
private
+ FAutoSelect: Boolean;
+ FAutoSelected: Boolean;
FCharCase: TEditCharCase;
FEchoMode: TEchoMode;
FMaxLength: Integer;
@@ -618,6 +634,8 @@ type
procedure CreateWnd; override;
procedure TextChanged; override;
procedure Change; dynamic;
+ procedure DoEnter; override;
+ procedure DoExit; override;
function GetSelLength: integer; virtual;
function GetSelStart: integer; virtual;
function GetSelText: string; virtual;
@@ -630,6 +648,9 @@ type
function ChildClassAllowed(ChildClass: TClass): boolean; override;
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
procedure WMChar(var Message: TLMChar); message LM_CHAR;
+ procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X, Y: Integer); override;
+ property AutoSelect: Boolean read FAutoSelect write FAutoSelect default False;
+ property AutoSelected: Boolean read FAutoSelected write FAutoSelected;
public
constructor Create(AOwner: TComponent); override;
procedure Clear;
@@ -721,11 +742,14 @@ type
{ TEdit }
TEdit = class(TCustomEdit)
+ public
+ property AutoSelected;
published
property Action;
property Align;
property Anchors;
property AutoSize;
+ property AutoSelect;
property BorderSpacing;
property Color;
property Constraints;