--- ibx/trunk/ibcontrols/IBLookupComboEditBox.pas 2018/03/16 10:27:26 217 +++ ibx/trunk/ibcontrols/IBLookupComboEditBox.pas 2018/04/03 09:09:05 225 @@ -345,6 +345,7 @@ begin sCompleteText := ListSource.DataSet.FieldByName(ListField).AsString; if (sCompleteText <> FCurText) then begin + KeyValue := ListSource.DataSet.FieldByName(KeyField).AsVariant; sResultText := sCompleteText; if ((cbactEndOfLineComplete in AutoCompleteText) and (cbactRetainPrefixCase in AutoCompleteText)) then @@ -354,9 +355,8 @@ begin end; Text := sResultText; SelStart := iSelStart; - SelLength := UTF8Length(Text); + SelLength := UTF8Length(Text) - iSelStart; end; - KeyValue := ListSource.DataSet.FieldByName(KeyField).AsVariant; end else begin @@ -512,12 +512,24 @@ begin SelectAll; end else + if AutoComplete and (Style <> csDropDownList) then begin - FTimer.Interval := 0; - if (IsEditableTextKey(Key) or (Key = VK_BACK)) - and AutoComplete and (Style <> csDropDownList) and - (not (cbactEndOfLineComplete in AutoCompleteText) or (SelStart = UTF8Length(Text))) then + if (Key = VK_BACK) or (Key = VK_DELETE) then + begin + if SelStart = 0 then + begin + SelStart := UTF8Length(Text); + SelLength := 0; + end; + FTimer.Interval := 0; + end + else + if IsEditableTextKey(Key) and + (not(cbactEndOfLineComplete in AutoCompleteText) or (SelStart = UTF8Length(Text))) then + begin + FTimer.Interval := 0; FTimer.Interval := FKeyPressInterval; + end; end; end; @@ -537,6 +549,8 @@ end; procedure TIBLookupComboEditBox.SetItemIndex(const Val: integer); begin + if Val > 0 then + FCurText := ''; inherited SetItemIndex(Val); FLastKeyValue := KeyValue; end; @@ -562,6 +576,8 @@ end; procedure TIBLookupComboEditBox.UpdateData(Sender: TObject); begin inherited UpdateData(Sender); + if FCurText <> '' then + Text := FCurText + Text; FModified := false; end; @@ -597,6 +613,7 @@ begin FForceAutoComplete := false; end; CheckAndInsert; + FCurText := ''; if FModified then Change; {ensure Update} inherited EditingDone;