I'm using Lazarus 2.02 (32 bit Carbon) to produce macOS 64 bit binaries.it should be working for 2.0.2
I had a similar problem in Linux and now I always use SetFocusedControl(), Also the TabSheet must be visible so I set the focusing in a handler for the TPageControl.OnChange event.
Sample project attached.Thank you. I can see the problem (the issue is with tab change events actually within Cocoa-Widgetset. Not much you can do about it.).
procedure TForm1.deviceEditKeyUp(Sender: TObject);
var
i: integer;
tempStr: String;
begin
try
for i := 0 to picListBox.Items.Count - 1 do
if(AnsiStartsText(deviceEdit.Text, picListBox.Items[i]) = True) then
begin
picListBox.ItemIndex := i;
picListBox.TopIndex := picListBox.ItemIndex;
break;
end;
finally
if(i = picListBox.Items.Count - 1) then
begin
MakeBeep; // Alert user
tempStr := deviceEdit.Text;
delete(tempStr, Length(tempStr), 1); // remove unmatching char
deviceEdit.Text := tempStr;
end;
end;
end;
what is deviceEditKeyUp?
it looks like an event handler. But keyup event handler comes with additional parameters (key code and shift state)
If it's an event handler, what event does it process?
as usual - sample projects help.
The compiler kept complaining (hinting) about the unused key and shift args, removing them shut it up and didn't seem to cause any issues.I've a bad feeling about this!
I can see it works just fine for all options in the given List.
Except for the last one.
procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
);
var
i: integer;
tempStr: String;
found: Boolean;
begin
Caption := Edit1.Text;
try
found := false;
for i := 0 to ListBox1.Items.Count - 1 do
begin
//ShowMessage(picListBox.Items[i]);
if(AnsiStartsText(Edit1.Text, ListBox1.Items[i]) = True) then
begin
ListBox1.ItemIndex := i;
ListBox1.TopIndex := ListBox1.ItemIndex;
found := true;
Caption := Caption +' '+IntToStr(i);
break;
end;
end;
finally
if (not found) then
begin
//MakeBeep; // Alert user
tempStr := Edit1.Text;
delete(tempStr, Length(tempStr), 1); // remove unmatching char
Edit1.Text := tempStr;
end;
end;
end;
What is in the form caption when you try to type for the first time.