Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: FireMonkey TEdit KeyDown and KeyUp events on iOS


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Nov 16, 2017 2:06 PM Last Post By: Jako Grobler
Jako Grobler

Posts: 45
Registered: 6/26/15
FireMonkey TEdit KeyDown and KeyUp events on iOS  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 2, 2017 9:59 AM
How can I detect when a user presses the Enter/Go key on the iOS virtual keyboard while in a TEdit? The KeyDown and KeyUp events are firing in Android, but not in iOS.

Thanks in advance!

PS: Strangely enough, they do fire in iOS for TSearchBox...
Jako Grobler

Posts: 45
Registered: 6/26/15
Re: FireMonkey TEdit KeyDown and KeyUp events on iOS  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 3, 2017 9:49 AM   in response to: Jako Grobler in response to: Jako Grobler
Jako Grobler wrote:
How can I detect when a user presses the Enter/Go key on the iOS virtual keyboard while in a TEdit? The KeyDown and KeyUp events are firing in Android, but not in iOS.

Thanks in advance!

PS: Strangely enough, they do fire in iOS for TSearchBox...

So I found this ticket:

https://quality.embarcadero.com/browse/RSP-9416

Working as intended? Erm... So how do I capture the "Go" (Enter) key event of a TEdit in iOS to actually trigger an action? Is there another way other than the key events?
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: FireMonkey TEdit KeyDown and KeyUp events on iOS  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 3, 2017 12:55 PM   in response to: Jako Grobler in response to: Jako Grobler
Jako Grobler wrote:

How can I detect when a user presses the Enter/Go key on the iOS virtual keyboard while in a TEdit? The KeyDown and
KeyUp events are firing in Android, but not in iOS.

They fire OK for me. Steps:

1. Create a multiplatform app
2. Put a TEdit on the form
3. Code the OnKeyDown thus:

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
  if Key = vkReturn then
    Sleep(0);
end;


4. Put a breakpoint on the Sleep statement.
5. Start the app, set focus on the edit
6. Tap the Return key on the VK

Expected: stops at the Sleep statement

Works for ControlType of Styled or Platform on iOS Device 32bit, 64bit or Simulator

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com
Jako Grobler

Posts: 45
Registered: 6/26/15
Re: FireMonkey TEdit KeyDown and KeyUp events on iOS  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 3, 2017 2:12 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Jako Grobler wrote:

How can I detect when a user presses the Enter/Go key on the iOS virtual keyboard while in a TEdit? The KeyDown and
KeyUp events are firing in Android, but not in iOS.

They fire OK for me. Steps:

1. Create a multiplatform app
2. Put a TEdit on the form
3. Code the OnKeyDown thus:

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
  if Key = vkReturn then
    Sleep(0);
end;


4. Put a breakpoint on the Sleep statement.
5. Start the app, set focus on the edit
6. Tap the Return key on the VK

Expected: stops at the Sleep statement

Works for ControlType of Styled or Platform on iOS Device 32bit, 64bit or Simulator

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com

Nope. Tried already. Tried again just now to make sure. iPad Mini 4. It never hits the breakpoint. It does hit the breakpoint for a TSearchBox keydown though. Not styled though, set to Platform since we need dictation enabled on all our edit controls.

I forgot to mention: Delphi Berlin, not Tokyo. The hamburger menu freeze the app intermittently in Tokyo for some reason and then the app closes, at least for me. Fell back to Berlin.
Jako Grobler

Posts: 45
Registered: 6/26/15
Re: FireMonkey TEdit KeyDown and KeyUp events on iOS  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 16, 2017 2:06 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Jako Grobler wrote:

How can I detect when a user presses the Enter/Go key on the iOS virtual keyboard while in a TEdit? The KeyDown and
KeyUp events are firing in Android, but not in iOS.

They fire OK for me. Steps:

1. Create a multiplatform app
2. Put a TEdit on the form
3. Code the OnKeyDown thus:

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
  if Key = vkReturn then
    Sleep(0);
end;


4. Put a breakpoint on the Sleep statement.
5. Start the app, set focus on the edit
6. Tap the Return key on the VK

Expected: stops at the Sleep statement

Works for ControlType of Styled or Platform on iOS Device 32bit, 64bit or Simulator

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com

I was playing around on a small sample app and figured it out. The TEdit was set to "Platform".

Just found this: http://docwiki.embarcadero.com/RADStudio/Berlin/en/FireMonkey_Native_iOS_Controls#Limitations_of_Native_iOS_Controls

OnKeyDown and OnKeyUp event handlers are not supported

Problem is we need native to support voice dictation in iOS as well... Anybody has a workaround to detect the Enter key?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02