Hi
Looking for opinions and logic that might extend beyond mine(easy)
Extending the ComboBox to monitor user input and make sure that what is entered, exists in the item list.
KeyPress does not fire under certain conditions which I do not feel is right (My logic at least)
procedure TTestComboBox.KeyPress(var Key: Char);
const
CrLf = #13#10;
var
s, t, tt: string;
i, pp: Integer;
begin
inherited;
if Key < ' ' then Exit; //Ignore control characters
i := SelStart;
t := Text;
s := Copy(t, 1, i) + Key;
tt := Items.Text;
pp := Pos(CrLf+s, CrLf+tt)
if pp > 0 then exit; //Text found in the item list
Key := #0; //Text not found in the item list so ignore key
end;
Findings
CharCase is set to:
ecNormal : KeyPress always fires
ecUpperCase: Only fires when entering an UpperCase Char
ecLowerCase: Only fires when entering a LowerCase Char
Expected
KeyPress should always fire and Key should just be in the selected Case
OS Win10 (Not tested on other OS)
FPC 3.2.3
Laz 3.4
Widgetset Win32/Win64 (Others not tested)