diff --git a/lcl/include/customcombobox.inc b/lcl/include/customcombobox.inc index 7f5614e756..670d719e62 100644 --- a/lcl/include/customcombobox.inc +++ b/lcl/include/customcombobox.inc @@ -482,21 +482,24 @@ begin end; procedure TCustomComboBox.KeyUp(var Key: Word; Shift: TShiftState); -var iSelStart: Integer; - sCompleteText, sPrefixText, sResultText: string; +var + iSelStart: Integer; // byte position + sCompleteText, sPrefixText, sResultText: string; begin inherited KeyUp(Key, Shift); if ((cbactEnabled in FAutoCompleteText) and (Style <> csDropDownList)) then begin //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 + begin if (Key = VK_RETURN) then - SelectAll else - begin + SelectAll + else begin iSelStart := SelStart;//Capture original cursor position //End of line completion - if ((iSelStart < Length(Text)) and (cbactEndOfLineComplete in FAutoCompleteText)) then Exit; + if ((iSelStart < Length(Text)) + and (cbactEndOfLineComplete in FAutoCompleteText)) then + Exit; sPrefixText := LeftStr(Text, iSelStart); sCompleteText := GetCompleteText(Text, iSelStart, (cbactSearchCaseSensitive in FAutoCompleteText), diff --git a/lcl/stdctrls.pp b/lcl/stdctrls.pp index ddbd888cc8..60662dcb07 100644 --- a/lcl/stdctrls.pp +++ b/lcl/stdctrls.pp @@ -378,8 +378,8 @@ type property Items: TStrings read FItems write SetItems; property ItemIndex: integer read GetItemIndex write SetItemIndex default -1; property ReadOnly: Boolean read FReadOnly write SetReadOnly stored IsReadOnlyStored; - property SelLength: integer read GetSelLength write SetSelLength; - property SelStart: integer read GetSelStart write SetSelStart; + property SelLength: integer read GetSelLength write SetSelLength;// byte length + property SelStart: integer read GetSelStart write SetSelStart;// byte position property SelText: String read GetSelText write SetSelText; property Style: TComboBoxStyle read FStyle write SetStyle; property Text;