Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   Wie nun InputQuery unter IOS nutzen? (https://www.delphipraxis.net/210518-wie-nun-inputquery-unter-ios-nutzen.html)

Harry Stahl 5. Mai 2022 21:53

Wie nun InputQuery unter IOS nutzen?
 
Bis Delphi 10.3.3 und IOS 12.1 hat noch folgendes bei Klick auf einen Schalter funktioniert:

Delphi-Quellcode:
procedure Tfrm_fldverw.bnNewClick(Sender: TObject);
var
  NewString: String; P : Integer;
begin
  InputQuery ('Neue Bezeichnung anlegen...', ['Bitte geben Sie einen Text ein:'], [NewString],
    procedure (const AResult: TModalresult; const AValues: array of string)
    begin
      if AResult= mrOK then begin
        P := lbKat.Items.Add (AValues[0]);
        lbKat.ItemIndex := P;
      end;
    end);
end;
Nun soll man wohl Inputquerysync (oder Async) verwenden:

https://docwiki.embarcadero.com/Libr...InputQuerySync


Aber beides funktioniert hier nicht:

Die Async-Variante kommt immer mit result 0 2 (cancel) zurück.

Delphi-Quellcode:
procedure Tfrm_fldverw.bnNewClick(Sender: TObject);
var
  ASyncService : IFMXDialogServiceASync;
  caption, inData: array[0..0] of string;
  P: Integer;

  SyncService : IFMXDialogServiceSync;
  Acaption, AinData : array[0..0] of string;

begin
  caption[0]  := 'Neue Bezeichnung :';
  inData[0] := '';

  // funktioniert nicht
  if TPlatformServices.Current.SupportsPlatformService (IFMXDialogServiceSync, IInterface(SyncService)) then
  begin
    if SyncService.InputQuerySync( 'Input String', caption, inData ) then begin
       P := lbKat.Items.Add (indata[0]);
       lbKat.ItemIndex := P;
    end;
  end;

  // das auch nicht, als Ergebnis kommt als result immer "2" zurück (cancel)
  if TPlatformServices.Current.SupportsPlatformService (IFMXDialogServiceAsync, IInterface (ASyncService)) then
  begin
    ASyncService.InputQueryAsync( 'Input String', caption, inData,
      procedure (const AResult : TModalResult; const AValues : array of string)
      var s: string;
      begin
         case AResult of
           mrOK: begin
             s := AValues[0];
             P := lbKat.Items.Add (AValues[0]);
             lbKat.ItemIndex := P;
           end;
         end;
      end );
  end;

(*
var
  NewString: String; P : Integer;
begin
  InputQuery ('Neue Bezeichnung anlegen...', ['Bitte geben Sie einen Text ein:'], [NewString],
    procedure (const AResult: TModalresult; const AValues: array of string)
    begin
      if AResult= mrOK then begin
        P := lbKat.Items.Add (AValues[0]);
        lbKat.ItemIndex := P;
      end;
    end);
*)
end;
Was mache ich falsch, wie geht es richtig?

Rollo62 6. Mai 2022 10:57

AW: Wie nun InputQuery unter IOS nutzen?
 
Du brauchst doch eigentlich nur von der globalen Procedure auf die entsprechenden globalen class procedures umzustellen:

Delphi-Quellcode:
class procedure TDialogService.InputQuery(const ACaption: string; const APrompts: array of string; const AValues: array of string; const ACloseQueryProc: TInputCloseQueryProc);

...

FMX.DialogService.TDialogService
    {} .InputQuery( ACaption,
                    APrompts,
                    AValues,
                    LProcDlg );

Harry Stahl 6. Mai 2022 13:48

AW: Wie nun InputQuery unter IOS nutzen?
 
@Rollo62

Danke. Ich meine, ich hätte es so versucht - werde ich aber beim nächsten Programm noch mal so angehen (jetzt habe ich einfach eine eigene Form für die Texteingabe gemacht)....


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:08 Uhr.

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