Recent

Author Topic: More of TEdit not editable  (Read 8449 times)

pleoman

  • New Member
  • *
  • Posts: 15
More of TEdit not editable
« on: September 22, 2021, 11:11:19 pm »
I have read the information about "Edit not editable" on the forum, Dec. 9, 2020, but suggestions there did not help me.
  I am updating a fairly large program that was written with Lazarus in 2016 for a MacBook Pro. I need to update to 64 bit architecture.
  The program is called MDeq.app, and the earlier version can be seen at
https://casconorwich.org/pages/math.html. The Windows version is WDeq.exe.

Now, I have updated and installed the following packages:
fpc-3.2.2.intelarm64-macosx.dmg, fpc-src-3.2.2-2-laz.pkg and Lazarus-2.2.0RC1-x86_64-macosx.pkg
They are working fine on a MacBook Pro running Big Sur ver. 11.5.2 with intel core7. I am using the LCL widgetset "cocoa", and debugging with LLDB.

  After some editing, I have been able to get everything working except one dialog form. I have about 5 dialog forms, and they're working fine, and the code for them is identical in every way to the problem dialogue form. At the main menu, I open the problem dialogue form to enter initial conditions for a set of differential equations. Each TEdit control shows its default values, and the cursor is blinking in the Edit1 control, as it should. But no edit control will accept any keystrokes. I can tab through controls, including the OK and Cancel buttons, which all work fine. Only the TEdit controls don't work.  BUT..., if I left click on the top of the Dialogue form once, then everything works exactly as it should and all TEdit controls accept the keystrokes. Can someone explain what is changing when I click on the top of the form, and can I write some code or change a setting to fix this.
Thanks for any help,
Ernie

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: More of TEdit not editable
« Reply #1 on: September 23, 2021, 01:47:13 am »
do you launch your application using bundle?
on macOS you should be using bundles.

When do you show the dialog? do you do ShowModal in FormShow event?

can you make a sample of project? (just remove all the functionality and leave the dialogs to demonstrate the problem)
« Last Edit: September 23, 2021, 01:54:41 am by skalogryz »

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Re: More of TEdit not editable
« Reply #2 on: September 23, 2021, 07:52:19 am »
It seems that the focused form is moved away from the dialog form somehow.

AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
Re: More of TEdit not editable
« Reply #3 on: September 24, 2021, 01:01:15 pm »
Pls give the compilable small project.

pleoman

  • New Member
  • *
  • Posts: 15
Re: More of TEdit not editable
« Reply #4 on: September 25, 2021, 01:37:33 am »
  I've been working with some of your suggestions, but the TEdit control is still giving me problems. I am using several dialog forms that are working fine. The Change1Dlg dialogue form is used in 5 different places. It works fine on 4 of them. I'm enclosing 2 procedures: ChangeStep works fine, but Drawvert won't accept any entry in the TEdit control, unless I left-click on the top of the form first. The Chage1Dlg form is created initially. None of its settings are changed in the program. All variables are declared and initialized. Convert is a procedure that parses strings into math functions and numbers. It's working fine everywhere in the program.  When I click on one of these items on the TMenu form, it immediately calls the 2 procedures I've included here, so nothing different has happened before the Procedure is called. The application is using bundles.  The Change1Dlg dialogue form has one Edit control, a bevel, a label, an OK and Cancel button, and that's it.   

Code: Pascal  [Select][+][-]
  1. Procedure ChangeStep;
  2.  Var s:string; tmp: Double;
  3.  Begin
  4.  With Change1Dlg do
  5.   Begin
  6.   ActiveControl:=Edit1;
  7.   Edit1.AutoSelect:=True;
  8.   Caption:=' Stepsize';
  9.   Label1.Caption:='Reduce stepsize to compute more values';
  10.   Str(h:6:5,s);  
  11.   Edit1.Text:=s;
  12.   If Showmodal<>mrCancel then
  13.    Begin
  14.    tmp:=h;
  15.    Convert(Edit1.Text,h);
  16.    If Edit1.Text='' then
  17.    h:=tmp;
  18.    end;
  19.   end;      
  20.  
  21.  Procedure DrawVert;
  22.  var  Vert1, Vert2:Integer; s:string;  tmp:Double;
  23.  Begin
  24.  With Change1Dlg Do
  25.   begin
  26.   ActiveControl:=Edit1;
  27.   Edit1.AutoSelect:=True;
  28.   Caption:='Vertical Line';
  29.   Label1.Caption:='Draw a Vertical Line at X=';
  30.   Str(Xvert:6:2,s);
  31.   Edit1.Text:=s;
  32.  
  33.  If Showmodal<>mrCancel then
  34.   Begin
  35.   tmp:=Xvert;
  36.   Convert(Edit1.Text,Xvert);
  37.   If Edit1.Text='' then
  38.   Xvert:=tmp;
  39.   end;
  40.  end;
  41.  
  42.  { The rest just draws a vertical line}
  43.   Shape(Xvert,Miny,Vert1,Vert2);
  44.    begin
  45.   With  DeqScrn1.Image1.Canvas do
  46.    begin
  47.   Pen.Color:=DColor;
  48.    Moveto(Vert1,Vert2);
  49.    Shape(Xvert,Maxy,Vert1,Vert2);
  50.    Lineto(Vert1,Vert2);
  51.    end;
  52.    With  Picmap.Canvas do
  53.    begin
  54.    Pen.Color:=DColor;
  55.    Picmap.Canvas.Moveto(Vert1,Vert2);
  56.    Shape(Xvert,Maxy,Vert1,Vert2);
  57.    Picmap.Canvas.Lineto(Vert1,Vert2);
  58.   end;
  59.   end;
  60.   End;
           

[Edited to add CODE tags - please read How to use the Forum.]
« Last Edit: September 25, 2021, 08:37:54 am by trev »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: More of TEdit not editable
« Reply #5 on: September 25, 2021, 08:40:58 am »
It would be helpful to attach (not dump into a post) a small compilable project demonstrating your issue. Lazarus can help - see Publish project Package.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: More of TEdit not editable
« Reply #6 on: September 25, 2021, 08:21:08 pm »
are you trying to show a model dialog while your draw something?
it's a bit unwelcomed by Cocoa. Is it possible to collect the necessary information before drawing?

pleoman

  • New Member
  • *
  • Posts: 15
Re: More of TEdit not editable
« Reply #7 on: September 29, 2021, 03:53:31 pm »
 Sorry to be late on responding, my time is limited.
  After numerous efforts, I've noticed that when I click on a TMainmenu item to open a Dialog form, if that menu item has no submenu, then the TEdit control on the Dialog form will not accept any text. One example was the DrawVert procedure provided earlier that was called by the menu item Vert. When I added a submenu to Vert and included the same OnClick event as I had with Vert, the Change1Dlg form opened and the TEdit control worked fine. Weird, but I have had trouble with the TMainmenu before. In particular, if I just hover over an item on the menu, it will open up an item, sometimes more than one item. ( As an aside note, before I added a submenu to Vert, I had assigned a shortcut, Alt+V to Vert. If I use the shortcut instead of clicking on the main menu, the Dialog form opens and works perfectly)
  Anyway, this is a simple solution to my problem. I would be happy to attach the code for this project if anyone is interested. I thank all of you for your interest and help. Perhaps the TMainmenu form needs a look? 

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: More of TEdit not editable
« Reply #8 on: September 29, 2021, 09:46:53 pm »
please attach the sample project

pleoman

  • New Member
  • *
  • Posts: 15
Re: More of TEdit not editable
« Reply #9 on: October 02, 2021, 04:12:30 pm »
I can't attach the entire project because it's too big. I'll try to create a smaller example using the TMainmenu component.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: More of TEdit not editable
« Reply #10 on: October 02, 2021, 11:05:02 pm »
I'll try to create a smaller example using the TMainmenu component.
we're looking forward!

pleoman

  • New Member
  • *
  • Posts: 15
Re: More of TEdit not editable
« Reply #11 on: October 03, 2021, 03:24:35 pm »
I've attached a project with a TMainmenu with 2 items that open the same dialog form. Item1 opens a form where TEdit is not editable, Item2 has a submenu that opens the same form and TEdit is editable.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: More of TEdit not editable
« Reply #12 on: October 05, 2021, 01:22:31 am »
The way you're using the main menu is pretty somewhat sensitive for macOS implementations.
I don't have any definite resolution yet for the problem. The most reliable way would be to change UI so the dialog is shown by a sub-menu item rather than the top-level menu...
...yet the sample also discovered some bugs in the implementation.

Fixing those should help with your problem as well.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: More of TEdit not editable
« Reply #13 on: October 10, 2021, 04:31:43 am »
I have the problem fixed for you.

if you get the code from here: https://github.com/skalogryz/Lazarus/tree/cocoa
then the modal window should behave for you properly in either case

pleoman

  • New Member
  • *
  • Posts: 15
Re: More of TEdit not editable
« Reply #14 on: October 12, 2021, 02:49:59 pm »
Hi skalogryz,
I looked at your url  https://github.com/skalogryz/Lazarus/tree/cocoa
There's lots of code there, but I'm not sure which code you're referring to.
Pleoman

 

TinyPortal © 2005-2018