Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Collection TextField and Keyboard

 Post Reply Post Reply
Author
Randall Ken View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 Oct 2014
Posts: 646
Post Options Post Options   Quote Randall Ken Quote  Post ReplyReply Direct Link To This Post Topic: Collection TextField and Keyboard
    Posted: 26 Feb 2015 at 10:43am
Hi,

I'm using a TTMSFMXNativeUICollectionViewTemplateTextField when editing on an iPad the keyboard hide/collapse button works as expected but on an iPhone the Done button doesn't do anything.

Ken
Back to Top
Pieter Scheldeman View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 3300
Post Options Post Options   Quote Pieter Scheldeman Quote  Post ReplyReply Direct Link To This Post Posted: 27 Feb 2015 at 10:30am
the done button is added programmatically in the FireMonkey framework which hooks onto the virtual keyboard. (FMX.VirtualKeyboard.iOS.pas) this hooking only works for FireMonkey controls.

     if not Assigned(FHideButton) then
      begin
        FHideButton := TUIBarButtonItem.Create;
        FHideButton.setTitle(StrToNSStr(SEditorDone));
        FHideButton.setStyle(UIBarButtonItemStyleDone);
        FHideButton.setTarget(FKeyboardHandler.GetObjectID);
        FHideButton.setAction(sel_getUid('HideVirtualKeyboard'));
      end;

procedure TKeyboardEventHandler.HideVirtualKeyboard;
begin
  try
    Screen.ActiveForm.Focused := nil;
  except
    Application.HandleException(Screen.ActiveForm);
  end;
end;

It's unclear how this could be solved on our side, because the hooking shouldn't be necessary when using native controls.

Kind Regards, 
Pieter


Edited by Pieter Scheldeman - 27 Feb 2015 at 10:30am
Back to Top
Randall Ken View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 Oct 2014
Posts: 646
Post Options Post Options   Quote Randall Ken Quote  Post ReplyReply Direct Link To This Post Posted: 27 Feb 2015 at 12:08pm
Thanks for the info but doesn't really help :)

How come it works on an iPad but not an iPhone?
Back to Top
Pieter Scheldeman View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 3300
Post Options Post Options   Quote Pieter Scheldeman Quote  Post ReplyReply Direct Link To This Post Posted: 27 Feb 2015 at 12:25pm
This was just for clarification that it's the code from the FireMonkey source that interferes with this process.

on iPad, the done button isn't created and thus it doesn't interferes with the virtual keyboard. the virtual keyboard is different, and has an additional button to close the keyboard. It could be possible that you will have to set the focus to a FireMonkey control when starting the editing on the native UITextView control. The OnItemTextViewDidBeginEditing event could be used for this.

Kind Regards, 
Pieter

Back to Top
Randall Ken View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 Oct 2014
Posts: 646
Post Options Post Options   Quote Randall Ken Quote  Post ReplyReply Direct Link To This Post Posted: 01 Mar 2015 at 8:30am
Pieter,

Users should surely expect something so fundamental on the keyboard as the Done button to work.

Ken
Back to Top
Pieter Scheldeman View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 3300
Post Options Post Options   Quote Pieter Scheldeman Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2015 at 8:48am
Dear Ken, 

The done button is something that is added hardcoded by the FireMonkey framework. As FireMonkey interferes with this process to support FireMonkey controls there is no way to intercept this event, or hide the done button. We will further investigate this here but please understand that is a technical issue that we'll have to overcome.

Kind Regards, 
Pieter
Back to Top
Randall Ken View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 Oct 2014
Posts: 646
Post Options Post Options   Quote Randall Ken Quote  Post ReplyReply Direct Link To This Post Posted: 03 Mar 2015 at 9:14am
Thanks, understood and appreciated but until resolved it makes these controls unusable for editing.

Ken
Back to Top
Randall Ken View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 Oct 2014
Posts: 646
Post Options Post Options   Quote Randall Ken Quote  Post ReplyReply Direct Link To This Post Posted: 19 Mar 2015 at 1:43pm
Can you please let me know if you are likely to be able to resolve this?

Ken
Back to Top
Randall Ken View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 Oct 2014
Posts: 646
Post Options Post Options   Quote Randall Ken Quote  Post ReplyReply Direct Link To This Post Posted: 11 Aug 2015 at 10:00am
Is there an update on this as iCL is unusable without this being remedied!
Back to Top
Pieter Scheldeman View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 3300
Post Options Post Options   Quote Pieter Scheldeman Quote  Post ReplyReply Direct Link To This Post Posted: 11 Aug 2015 at 10:53am
Hi, 

Please note that the default virtual keyboard on iOS 7/8 for iPhone does not contain a done key. The done button as explained in the previous posts is added by Embarcadero which intercepts the virtual keyboard handling, but there is no way to intercept this from a native control.

The only workaround to hide the keyboard is to change the return key type directly on the native control which will change the return key to a done key and clicking it will hide the keyboard.

procedure TForm1.TMSFMXNativeUICollectionView1AddItemControl(Sender: TObject;
  AControl: TTMSFMXNativeUICollectionViewTemplateControl);
begin
  AsTextField(AControl).TextField.setReturnKeyType(UIReturnKeyDone);
end;

Kind Regards, 
Pieter
Back to Top
Jakobsen Hans View Drop Down
New Member
New Member
Avatar

Joined: 30 Dec 2014
Posts: 19
Post Options Post Options   Quote Jakobsen Hans Quote  Post ReplyReply Direct Link To This Post Posted: 02 Sep 2019 at 3:37pm
I found this thread because I had the same problem. I have solved with the procedure below, which hides this default FMX toolbar on the keyboard. Now I can create my own toolbar to the keyboard (simply use the iCL UIToolbar implementation) and assign it to the keyboard for a textfield using this line:
    MyTMSNativeUITextField.TextField.setInputAccessoryView(MyTMSNativeUIToolBar.ToolBar);

procedure HideFMXKeyboardToolbar;
var
  lToolbarService: IFMXVirtualKeyboardToolbarService;
begin
  TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardToolbarService, IInterface(lToolbarService));
  if lToolbarService<>nil then
    lToolbarService.SetToolbarEnabled(False);
end;

Back to Top
Pieter Scheldeman View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 3300
Post Options Post Options   Quote Pieter Scheldeman Quote  Post ReplyReply Direct Link To This Post Posted: 02 Sep 2019 at 3:39pm
Thanks Hans for the input!
Back to Top
Jakobsen Hans View Drop Down
New Member
New Member
Avatar

Joined: 30 Dec 2014
Posts: 19
Post Options Post Options   Quote Jakobsen Hans Quote  Post ReplyReply Direct Link To This Post Posted: 03 Sep 2019 at 5:25pm
You are welcome. I actually have a supplement for this, because I had big problems hiding the keyboard again. The normal way using Objective-C would be to call:
    MyTMSNativeUITextField.TextField.endEditing(true)

However, this only hides the custom toolbar of the keyboard (which indicates that the textfield actually stopped editing), but the keyboard remains open.
After hours of experimenting and testing, I found a way. Simply call this function after the EndEditing function above:

procedure HideNativeKeyboard;
var lKeyWindow: UIWindow;
begin
  lKeyWindow := SharedApplication.keyWindow;
  if lKeyWindow<>nil then
  begin
    if lKeyWindow.rootViewController <> nil then
      lKeyWindow.rootViewController.view.endEditing(true);
    lKeyWindow.endEditing(true);
  end;
end;

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down