Einzelnen Beitrag anzeigen

Benutzerbild von Harry Stahl
Harry Stahl

Registriert seit: 2. Apr 2004
Ort: Bonn
2.479 Beiträge
 
Delphi 11 Alexandria
 
#1

Wie nun InputQuery unter IOS nutzen?

  Alt 5. Mai 2022, 21:53
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?
  Mit Zitat antworten Zitat