Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Using input query on android.



Permlink Replies: 7 - Last Post: Oct 9, 2014 9:33 AM Last Post By: Remy Lebeau (Te...
Stev Warby

Posts: 50
Registered: 10/19/14
Using input query on android.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 27, 2014 4:27 AM
I see from the docs that I should use ACloseDialogProc.
What is the correct syntax please. I am using the delhi sqlite demo.

procedure TSQLiteForm.btnAddClick(Sender: TObject);
var
TaskName: String;
begin
try

if InputQuery('Enter New Task', 'Task', TaskName ) and not (TaskName.Trim = '') then
// InputQuery( const APrompts: array of string; const ADefaultValues: array of string; const ACloseQueryProc: TInputCloseQueryProc);
begin
SQLQueryInsert.ParamByName('TaskName').AsString := TaskName;
SQLQueryInsert.ExecSQL();
SQLDataSetTask.Refresh;
LinkFillControlToField1.BindList.FillList;
end;
except
on e: Exception do
begin
SHowMessage(e.Message);
end;
end;
end;

Cheers

Mr Warby
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Using input query on android.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 27, 2014 11:10 PM   in response to: Stev Warby in response to: Stev Warby
Try:
InputQuery('Enter New Task', 'Task', 
procedure(const AResult: TModalResult; const AValues: array of string)
begin
 
end;
);

http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.Dialogs.TInputCloseQueryProc
Stev Warby

Posts: 50
Registered: 10/19/14
Re: Using input query on android.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 3, 2014 2:08 PM   in response to: Eli M in response to: Eli M
I tried this on a button click ( Changed to clear any errors):

procedure TMasterDetailForm.Button1Click(Sender: TObject);
var
Task : String;
begin
InputQuery('Enter New Task', 'Task',
procedure(const AResult: TModalResult; const AValues: array of string)
begin
showmessage(Task);
end);
end;


I get error:

[DCC Error] MasterDetail.pas(96): E2250 There is no overloaded version of 'InputQuery' that can be called with these arguments

Cheers

Mr Warby

Stev Warby

Posts: 50
Registered: 10/19/14
Re: Using input query on android.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 3, 2014 2:19 PM   in response to: Stev Warby in response to: Stev Warby
I also tried:

begin
{ Show a multiple-button alert that triggers different code blocks according to
your input }
case MessageDlg('Choose a button:', System.UITypes.TMsgDlgType.mtInformation,
[
System.UITypes.TMsgDlgBtn.mbYes,
System.UITypes.TMsgDlgBtn.mbNo,
System.UITypes.TMsgDlgBtn.mbCancel
], 0) of
{ Detect which button was pushed and show a different message }
mrYES:
ShowMessage('You chose Yes');
mrNo:
ShowMessage('You chose No');
mrCancel:
ShowMessage('You chose Cancel');
end;
end;

From here :

http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE6/Object%20Pascal/Mobile%20Snippets/MessageAlerts/uMain.pas

but I still get the blocking error on the device.

What am I missing here

Cheers

MR Warby
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Using input query on android.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 3, 2014 3:33 PM   in response to: Stev Warby in response to: Stev Warby
I ditched InputQuery and got an InputBox working.

InputBox('What do you want to say?','','Stuff',
        procedure(const AResult: TModalResult; const AValue: string)
        begin
            case AResult of
              { Detect which button was pushed and show a different message }
              mrOk:
                begin
                  // AValue is the result of the inputbox dialog
                end;
              mrCancel:
                begin
                end;
           end;
        end
        );
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Using input query on android.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 3, 2014 3:36 PM   in response to: Stev Warby in response to: Stev Warby
Stev wrote:

I get error:

[DCC Error] MasterDetail.pas(96): E2250 There is no overloaded version
of 'InputQuery' that can be called with these arguments

Look more carefully at the overloaded signatures of InputQuery():

http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.Dialogs.InputQuery

All of the signatures that accept a callback procedure require an array of
strings in the second parameter, and none of them will accept the callback
procedure as the third parameter.

Try something more like this instead:

procedure TMasterDetailForm.Button1Click(Sender: TObject);
begin
  InputQuery('Enter New Task', ['Task'], [''],
    procedure(const AResult: TModalResult; const AValues: array of string)
    begin
      if AResult = mrOk then
        Showmessage(AValues[0]);
    end
  );
end;


--
Remy Lebeau (TeamB)
Stev Warby

Posts: 50
Registered: 10/19/14
Re: Using input query on android.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 9, 2014 7:02 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Stev wrote:

I get error:

[DCC Error] MasterDetail.pas(96): E2250 There is no overloaded version
of 'InputQuery' that can be called with these arguments

Look more carefully at the overloaded signatures of InputQuery():

http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.Dialogs.InputQuery

All of the signatures that accept a callback procedure require an array of
strings in the second parameter, and none of them will accept the callback
procedure as the third parameter.

Try something more like this instead:

procedure TMasterDetailForm.Button1Click(Sender: TObject);
begin
  InputQuery('Enter New Task', ['Task'], [''],
    procedure(const AResult: TModalResult; const AValues: array of string)
    begin
      if AResult = mrOk then
        Showmessage(AValues[0]);
    end
  );
end;


--
Remy Lebeau (TeamB)

I'm being really dumb here but can't get the syntax to use 'and not (TaskName.Trim = '') ' as in the first example.

Mr Warby

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Using input query on android.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 9, 2014 9:33 AM   in response to: Stev Warby in response to: Stev Warby
Stev wrote:

I'm being really dumb here but can't get the syntax to use
'and not (TaskName.Trim = '') ' as in the first example.

Try this:

uses
  ..., SysUtils; // for string.Trim()
 
procedure TSQLiteForm.btnAddClick(Sender: TObject);
begin
  InputQuery('Enter New Task', ['Task'], [''],
    procedure(const AResult: TModalResult; const AValues: array of string)
    begin
      if (AResult = mrOk) and (AValues[0].Trim <> '') then
      begin
        SQLQueryInsert.ParamByName('TaskName').AsString := AValues[0];
        SQLQueryInsert.ExecSQL;
        SQLDataSetTask.Refresh;
        LinkFillControlToField1.BindList.FillList;
      end;
    end;
  end;
end;


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02