Is there a way of restricting characters and specifying a keyboard type with Delphi's InputQuery / InputBox on Android?

+1 vote
asked Dec 22, 2015 by brian-frost

In my Delphi Android app I need to prompt the user for a value and one of the many overloaded calls to InputQuery seems (just) ok for the task. Since the value is numeric, I'd like to offer only the numeric keyboard popup and ideally to restrict the entry characters to numbers alone, much like you can do with the FireMonkey TEdit control's FilterChars property.

It would appear that there is no actual TEdit available since InputQuery etc uses platform services to implement the Android code using java calls.

Is there a way of influencing the 'default' style of keyboard that will be popped up prior to my call to InputQuery?

(I have already seen that I can do this with a TEdit, the EMB samples and this SO question ).

1 Answer

0 votes
answered Nov 29, 2018 by pax-beach

You can write your own class realizes Dialogs, or use ready example, like that.

Example looks like this:

procedure TFormMain.Button1Click(Sender: TObject);
var mY: TMyInputQuery;
begin mY := TMyInputQuery.Create(['Login:', 'Password:', 'aaaa', 'bbbb'], ['1', '2', '3', '4'], self, DialogEvent); mY.Edits[1].Password := true; mY.Edits[0].KillFocusByReturn := true; mY.Edits[0].ReturnKeyType := TReturnKeyType.Next; mY.Edits[1].KillFocusByReturn := true; mY.Edits[1].ReturnKeyType := TReturnKeyType.Next; mY.Edits[2].KillFocusByReturn := true; mY.Edits[2].ReturnKeyType := TReturnKeyType.Next; mY.Edits[2].KeyboardType := TVirtualKeyboardType.NumberPad; mY.Edits[3].KillFocusByReturn := true; mY.Edits[3].ReturnKeyType := TReturnKeyType.Next; mY.Edits[3].KeyboardType := TVirtualKeyboardType.PhonePad; mY.ShowMe;
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter