Recent

Author Topic: [SOLVED] Tedit issues  (Read 1745 times)

trev

  • Full Member
  • ***
  • Posts: 214
  • Former Delphi 7 and Delphi 10.2 User
Re: Tedit issues
« Reply #15 on: June 16, 2019, 08:52:26 am »
I restored all the missing args - no change.

The issue appears to be that when accessing the deviceEdit.Text in the procedure it has no content if it has been focused by deviceEdit.SetFocus! If I click another control, it loses focus as expected, and then once focused by a click deviceEdit.text has content again.

No luck creating a sample project yet :(
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

trev

  • Full Member
  • ***
  • Posts: 214
  • Former Delphi 7 and Delphi 10.2 User
Re: Tedit issues
« Reply #16 on: June 16, 2019, 09:53:14 am »
Sample project :)

As setup, Edit1.SetFocus is called from Form1.Activate handler. Typing in the edit control does not scroll the selection in ListBox1. Click another control, return to Edit1 and then it works.
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2269
    • havefunsoft.com
Re: Tedit issues
« Reply #17 on: June 16, 2019, 01:54:17 pm »
I can see it works just fine for all options in the given List.
Except for the last one.
(i.e. if one types "18" the last "8" would be removed, even though the option is in the list.)
In general it affects the selection of LAST item. (no matter what the text of it is)
However, it's caused by the code as well.


Code: Pascal  [Select]
  1. procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
  2.   );
  3. var
  4.   i: integer;
  5.   tempStr: String;
  6.   found : Boolean;
  7. begin
  8.   try
  9.     found := false;
  10.     for i := 0 to ListBox1.Items.Count - 1 do
  11.       begin
  12.       //ShowMessage(picListBox.Items[i]);
  13.       if(AnsiStartsText(Edit1.Text, ListBox1.Items[i]) = True) then
  14.         begin
  15.           ListBox1.ItemIndex := i;
  16.           ListBox1.TopIndex := ListBox1.ItemIndex;
  17.           found := true;
  18.           break;
  19.         end;
  20.       end;
  21.    finally
  22.     if (not found) then
  23.       begin
  24.         //MakeBeep;                           // Alert user
  25.         tempStr := Edit1.Text;
  26.         delete(tempStr, Length(tempStr), 1);  // remove unmatching char
  27.         Edit1.Text := tempStr;
  28.       end;
  29.    end;
  30. end;  
  31.  

https://www.dropbox.com/s/zico28gvlfhl47r/works.mov?dl=0
« Last Edit: June 16, 2019, 02:02:03 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

trev

  • Full Member
  • ***
  • Posts: 214
  • Former Delphi 7 and Delphi 10.2 User
Re: Tedit issues
« Reply #18 on: June 16, 2019, 02:18:02 pm »
I can see it works just fine for all options in the given List.
Except for the last one.

Weird. None of the options work for me. See pic eg.

(It was a sample to show the issue; the last item lost its 8 but that seemed not so important)
« Last Edit: June 16, 2019, 02:19:36 pm by trev »
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

trev

  • Full Member
  • ***
  • Posts: 214
  • Former Delphi 7 and Delphi 10.2 User
Re: Tedit issues
« Reply #19 on: June 16, 2019, 02:21:45 pm »
If I remove the Edit.SetFocus in the code OR if I click on another control then we have this pic.
« Last Edit: June 16, 2019, 02:24:02 pm by trev »
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2269
    • havefunsoft.com
Re: Tedit issues
« Reply #20 on: June 16, 2019, 02:26:28 pm »
try this code
Code: [Select]
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;
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

trev

  • Full Member
  • ***
  • Posts: 214
  • Former Delphi 7 and Delphi 10.2 User
Re: Tedit issues
« Reply #21 on: June 16, 2019, 02:39:13 pm »
Same problem - no matches unless I comment out the Edit1.SetFocus OR click on another control and return to typing in the Edit.
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2269
    • havefunsoft.com
Re: Tedit issues
« Reply #22 on: June 16, 2019, 02:55:34 pm »
It's not about matches, it's about the form caption.
What is in the form caption when you try to type for the first time.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

trev

  • Full Member
  • ***
  • Posts: 214
  • Former Delphi 7 and Delphi 10.2 User
Re: Tedit issues
« Reply #23 on: June 16, 2019, 02:59:28 pm »
Please see attached 7 second movie of the issue (using the new code). Rename file from .mpg to .mov (forum requirement)
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

trev

  • Full Member
  • ***
  • Posts: 214
  • Former Delphi 7 and Delphi 10.2 User
Re: Tedit issues
« Reply #24 on: June 16, 2019, 03:12:22 pm »
What is in the form caption when you try to type for the first time.

Nothing as per movie.
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2269
    • havefunsoft.com
Re: Tedit issues
« Reply #25 on: June 16, 2019, 03:18:17 pm »
what's you macOS version?

hmm is it the original sample project? or is this dialog - meaning it's a different form that opens?
« Last Edit: June 16, 2019, 03:19:55 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

trev

  • Full Member
  • ***
  • Posts: 214
  • Former Delphi 7 and Delphi 10.2 User
Re: Tedit issues
« Reply #26 on: June 16, 2019, 03:19:52 pm »
Mojave 10.14.5

It's the modified sample project as per your code (see caption after I click the second listbox)
« Last Edit: June 16, 2019, 03:22:49 pm by trev »
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2269
    • havefunsoft.com
Re: Tedit issues
« Reply #27 on: June 16, 2019, 03:23:33 pm »
try the latest trunk - r61401

i'm running Mojave 10.14.4 actually. But I don't think this is the problem.

Do you've any idea on why the form caption is blank in your video? It should be updated only on the first KeyUp event. It should be "Form1" from the start.
« Last Edit: June 16, 2019, 04:29:48 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

trev

  • Full Member
  • ***
  • Posts: 214
  • Former Delphi 7 and Delphi 10.2 User
Re: Tedit issues
« Reply #28 on: June 17, 2019, 02:10:51 am »
> try the latest trunk - r61401

Yes! It works! Thankyou.

> Do you've any idea on why the form caption is blank in your video?

No - the Object Inspector shows 'Form1' in the caption as does the design time form.

In my real application, it does show the form caption as it should.

I just changed the caption in the sample project from 'Form1' to 'Form 1' and it now shows up.
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)