Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   TEdit verursacht crash (https://www.delphipraxis.net/215613-tedit-verursacht-crash.html)

Borni 5. Aug 2024 15:47

TEdit verursacht crash
 
Hi Leute,

ich habe in einer Anwendung mehrere vererbte Formulare mit TLayouts die nacheinander geöffnet werden und automatisch wieder geschlossen, wenn man im Programm einen Home-Button drückt( alle Fenster werden dann geschlossen bis zum Hauptfenster).
Das lief schon seit Jahren einwandfrei bis zur Delphi 12.1

Sobald man in das TEdit-Eingabefeld klickt kommt es in 80% der Fälle zu einem Absturz unter iOS und Android (Win32/64 läuft).
Wird die Tastatur schwebend eingestellt, tritt der Fehler nicht auf ! ( äußerst merkwürdig).

Delphi 12.1 mit aktuellen SDK's, bei den devices spielt die Version keine Rolle.
So langsam gehen mir die Idee aus, was man noch probieren könnte.

Vielleicht hat ja jemand noch eine Idee.

LG Borni

Kas Ob. 5. Aug 2024 17:02

AW: TEdit verursacht crash
 
Hi,

I have very little knowledge here, i mean with Android and iOS, but
Zitat:

Zitat von Borni (Beitrag 1539581)
Wird die Tastatur schwebend eingestellt, tritt der Fehler nicht auf ! ( äußerst merkwürdig).

This, for me it make sense that resizing the form due the appearance of the keyboard has something to do with the crash, try to record/log the series of the event from TEdit having focus and the visible form triggered Resize event.... or similar event that has to do with resizing, but this is more like shooting darts in the dark.

Most importantly, try to log the exact exception message and call stack, it will help a lot in diagnosing this.

TurboMagic 8. Aug 2024 21:35

AW: TEdit verursacht crash
 
Hallo,

es ist auch möglich das Android Systemlog auf dem PC abzugreifen.
Früher hab's im SDK ein grafisches Tool, das ist aber nicht mehr.

Alternativ keine ich 2 Wege:

1. Ein grafisches Tool von Dave Notagge (hab' leider den Namen des Tools vergessen)

2. adb.exe, die Android Debug Bridge aus dem SDK hat einen Kommandozeilenparameter
-logcat oder so aber Achtung: das führt zu gaaaanz vielen Meldungen im Konsolenfenster.
Evtl. mittels "> <Dateiname>" in eine Datei speichern lassen und dann offline analysieren

In diesem Systemlog steht ab und zu nützliches drin.
Man kann von FMX aus auch reinschreiben: d.log('Meine Meldung');
Ist glaube ich in FMX.Types oder so definiert (sorry, weiß es gerade nicht auswendig und es
ist schon nach 22 Uhr...)

Borni 6. Sep 2024 12:28

AW: TEdit verursacht crash
 
Wir umgehen das ganze jetzt und überschreiben die original Routine, damit läuft es jetzt einwandfrei
Code:
{$IF DEFINED(iOS) or DEFINED(ANDROID)}
  var
    KeyboardDist : Single;
    FKBBounds: TRectF;
    Control: TControl;
{$ENDIF}

procedure Tmainform.FormVirtualKeyboardHidden(Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect);
begin
  {$IF DEFINED(iOS) or DEFINED(ANDROID)}
    if FocusedControl <> nil then
      if ((FocusedControl as TControl).Name = 'OriginText') or ((FocusedControl as TControl).Name = 'DestinationText') then
        begin
          Control := FindControlByName(SnapInLayout, 'RouteAddresses');
          if Assigned(Control) and (Control is TRectangle) then
            TRectangle(Control).Height := KeyboardDist;
        end;
    FKBBounds.Create(0, 0, 0, 0);
  {$ENDIF}
end;

procedure Tmainform.FormVirtualKeyboardShown(Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect);
{$IF DEFINED(iOS) or DEFINED(ANDROID)}
var
  Factor : Integer;
{$ENDIF}

begin
  {$IF DEFINED(iOS) or DEFINED(ANDROID)}
    try
      if (Screen.FocusControl <> nil) and (Screen.FocusControl is TMemo) then
        FocusedControl := TControl(Screen.FocusControl);
    except
      on E: Exception do
        Showmessage(E.Message);
    end;
    if FocusedControl <> nil then
      if (FocusedControl.Name = 'OriginText') or (FocusedControl.Name = 'DestinationText') then
        begin
          FKBBounds := TRectF.Create(Bounds);
          FKBBounds.TopLeft := ScreenToClient(FKBBounds.TopLeft);
          FKBBounds.BottomRight := ScreenToClient(FKBBounds.BottomRight);
          Control := FindControlByName(SnapInLayout, 'RouteAddresses');
          if FocusedControl.Name = 'OriginText' then
            Factor := 2
          else
            Factor := 1;
          if Assigned(Control) and (Control is TRectangle) then
            if Height - (FocusedControl.LocalToAbsolute(PointF(0, 0)).Y + FocusedControl.Height * Factor + 5)
               < FKBBounds.Height then
              begin
                KeyboardDist := TRectangle(Control).Height;
                TRectangle(Control).Height := TRectangle(Control).Height + (FKBBounds.Height -
                (Height - (FocusedControl.LocalToAbsolute(PointF(0, 0)).Y +
                     FocusedControl.Height * Factor + 5)));
              end;
      end;
  {$ENDIF}
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:44 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz