lcl: adding combobox readonly back. The indentation for the property is to work like TEdit.ReadOnly preventing user from editing combobox text field by manipulating the text.

Changes by selecting combobox items are to be allowed

git-svn-id: branches/comboboxreadonly@63237 -
This commit is contained in:
dmitry 2020-05-28 12:46:33 +00:00
parent b67240c535
commit bc8507e6b6
3 changed files with 21 additions and 0 deletions

View File

@ -42,6 +42,7 @@ begin
TWSCustomComboBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex);
TWSCustomComboBoxClass(WidgetSetClass).SetStyle(Self, FStyle);
TWSCustomComboBoxClass(WidgetSetClass).SetArrowKeysTraverseList(Self, FArrowKeysTraverseList);
TWSCustomComboBoxClass(WidgetSetClass).SetReadOnly(Self, FReadOnly);
TWSCustomComboBoxClass(WidgetSetClass).SetMaxLength(Self, FMaxLength);
TWSCustomComboBoxClass(WidgetSetClass).SetDropDownCount(Self, FDropDownCount);
@ -1080,6 +1081,16 @@ begin
end;
end;
procedure TCustomComboBox.SetReadOnly(const AValue: Boolean);
begin
if FReadOnly = AValue then
Exit;
FReadOnly := AValue;
if (not HandleAllocated) or (csLoading in ComponentState) then
Exit;
TWSCustomComboBoxClass(WidgetSetClass).SetReadOnly(Self, FReadOnly);
end;
{------------------------------------------------------------------------------
procedure TCustomComboBox.UpdateSorted;
------------------------------------------------------------------------------}

View File

@ -299,6 +299,7 @@ type
FOnGetItems: TNotifyEvent;
FOnMeasureItem: TMeasureItemEvent;
FOnSelect: TNotifyEvent;
FReadOnly: Boolean;
FSelLength: integer;
FSelStart: integer;
FSorted: boolean;
@ -314,6 +315,7 @@ type
procedure LMMeasureItem(var TheMessage: TLMMeasureItem); message LM_MeasureItem;
procedure LMSelChange(var TheMessage); message LM_SelChange;
procedure CNCommand(var TheMessage: TLMCommand); message CN_Command;
procedure SetReadOnly(const AValue: Boolean);
procedure UpdateSorted;
procedure SetArrowKeysTraverseList(Value: Boolean);
procedure WMChar(var Message: TLMChar); message LM_CHAR;
@ -411,6 +413,7 @@ type
property DropDownCount: Integer read FDropDownCount write SetDropDownCount default 8;
property Items: TStrings read FItems write SetItems;
property ItemIndex: integer read GetItemIndex write SetItemIndex default -1;
property ReadOnly: Boolean read FReadOnly write SetReadOnly default False;
property SelLength: integer read GetSelLength write SetSelLength;// UTF-8 length
property SelStart: integer read GetSelStart write SetSelStart;// UTF-8 position
property SelText: String read GetSelText write SetSelText;
@ -486,6 +489,7 @@ type
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ReadOnly;
property ShowHint;
property Sorted;
property Style;

View File

@ -86,6 +86,7 @@ type
class procedure SetItemIndex(const ACustomComboBox: TCustomComboBox; NewIndex: integer); virtual;
class procedure SetMaxLength(const ACustomComboBox: TCustomComboBox; NewLength: integer); virtual;
class procedure SetStyle(const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle); virtual;
class procedure SetReadOnly(const ACustomComboBox: TCustomComboBox; NewReadOnly: boolean); virtual;
class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; virtual;
class procedure FreeItems(var AItems: TStrings); virtual;
@ -470,6 +471,11 @@ class procedure TWSCustomComboBox.SetStyle(const ACustomComboBox: TCustomComboBo
begin
end;
class procedure TWSCustomComboBox.SetReadOnly(const ACustomComboBox: TCustomComboBox;
NewReadOnly: boolean);
begin
end;
class function TWSCustomComboBox.GetItems(const ACustomComboBox: TCustomComboBox
): TStrings;
begin