2
votes

I need to create custom keyboard for some TEdit in my (and only my) application for iOS8. Other edit`s need default iPad keyboard.

In Objective-C it`s look simple - just create UIView and assign it to myTextField.inputView (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextField_Class/index.html#//apple_ref/occ/instp/UITextField/inputView).

How can i do it in FMX (Delphi XE7)?

Update. UITextField declared in iOSapi.UIKit.pas and its corresponding control is TiOSNativeEdit in FMX.Edit.iOS.pas. In TEdit its used in PresentationProxy property, but only if ControlType = Platform. For example:

var
  intf: UITextField;
begin
  if edit1.PresentationProxy.HasNativeObject
    and (edit1.PresentationProxy.NativeObject.QueryInterface(UITextField, intf) = S_OK) then
    edit1.Text := 'Success'
  else
    edit1.Text := 'Failed';

After get UITextField interface (i think) you can do something like this:

intf.setInputView(myCreatedUIView);

But... i use styled controls, so this method not right for me.

So I have to emulate a keyboard using TFrame, TLayout, etc...

1

1 Answers

1
votes

After analyzing the source codes of FMX, I found a solution (only for IOS). Unfortunately, it's too big to include it here...

In short: you must use FMX.Types.RegisterShowVKProc(myKeyboardProc) Then you get the option to use your keyboard, but lose the system keyboard, keyboard toolbar and standard mechanism of interaction with them.

So, I create numpad and alphabet keyboards and use them.

My source code: custom keyboard for iOS

How to use: include uCommonCustomKeyboard.pas (this is main unit), ufrFullKeyboard.pas and ufrCustomNumpad.pas in your project. Thats all. If Delphi say "error reading property..." answer "Cancel" - this is because Delphi not recognize TFrame inheritance. For supported keyboard types see SupportedKeyboardTypes class function