Thread: How to reliably detect pressing of Return key on Android device?
 |
This question is not answered.
Helpful answers available: 2.
Correct answers available: 1.
|
|
Replies:
8
-
Last Post:
Mar 7, 2017 1:59 PM
Last Post By: Markus Humm
|
|
|
Posts:
5,113
Registered:
11/9/03
|
|
Hello,
given Delphi Berlin and a TEdit. I like to detect when the user presses Enter.
I implemented a OnTyping event already where I loop through all the chars of the .Text.
If vkLineFeed or vkReturn is detected it is Enter (vkLineFeed by finding out that certain devices
do send that one).
But now I encountered a device which simply closes the keyboard on enter but doesn't
send me a "enter" char. It's a LG L50 with Android 4.4.
Is there some method to reliably detect return presses on Android/FMX?
Greetings
Markus
|
|
|
Posts:
401
Registered:
4/13/09
|
|
Hello,
given Delphi Berlin and a TEdit. I like to detect when the user presses Enter.
I implemented a OnTyping event already where I loop through all the chars of the .Text.
If vkLineFeed or vkReturn is detected it is Enter (vkLineFeed by finding out that certain devices
do send that one).
But now I encountered a device which simply closes the keyboard on enter but doesn't
send me a "enter" char. It's a LG L50 with Android 4.4.
Is there some method to reliably detect return presses on Android/FMX?
Greetings
Markus
Tried anything like this on the keyup event?
procedure TForm38.Edit1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
begin
if key = vkreturn then showmessage('vkReturn') else
if key = vkLineFeed then showmessage('vkLineFeed') else
showmessage('Unknown : '+key.tostring);
end;
Only have a few devices to test with ... all returned vkReturn 
|
|
|
|
Posts:
5,113
Registered:
11/9/03
|
|
Am 06.03.2017 um 20:23 schrieb steven chesser:
Hello,
given Delphi Berlin and a TEdit. I like to detect when the user presses Enter.
I implemented a OnTyping event already where I loop through all the chars of the .Text.
If vkLineFeed or vkReturn is detected it is Enter (vkLineFeed by finding out that certain devices
do send that one).
But now I encountered a device which simply closes the keyboard on enter but doesn't
send me a "enter" char. It's a LG L50 with Android 4.4.
Is there some method to reliably detect return presses on Android/FMX?
Greetings
Markus
Tried anything like this on the keyup event?
procedure TForm38.Edit1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
begin
if key = vkreturn then showmessage('vkReturn') else
if key = vkLineFeed then showmessage('vkLineFeed') else
showmessage('Unknown : '+key.tostring);
end;
Only have a few devices to test with ... all returned vkReturn
Hello,
really the OnKeyUp event? How does this work for you?
I once tried to use this and when it never fired asked somewhere (most
likely here) about it and got the answer that it (rightfully) never
fires on Android. I created this QP entry then:
https://quality.embarcadero.com/browse/RSP-15822
Greetings
Markus
|
|
|
|
Posts:
5,113
Registered:
11/9/03
|
|
Am 06.03.2017 um 20:23 schrieb steven chesser:
Hello,
given Delphi Berlin and a TEdit. I like to detect when the user presses Enter.
I implemented a OnTyping event already where I loop through all the chars of the .Text.
If vkLineFeed or vkReturn is detected it is Enter (vkLineFeed by finding out that certain devices
do send that one).
But now I encountered a device which simply closes the keyboard on enter but doesn't
send me a "enter" char. It's a LG L50 with Android 4.4.
Is there some method to reliably detect return presses on Android/FMX?
Greetings
Markus
Tried anything like this on the keyup event?
procedure TForm38.Edit1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
begin
if key = vkreturn then showmessage('vkReturn') else
if key = vkLineFeed then showmessage('vkLineFeed') else
showmessage('Unknown : '+key.tostring);
end;
Only have a few devices to test with ... all returned vkReturn
Hello,
isn't ShowMessage a synchronous dialog?
If yes they won't work on Android as they're not allowed.
Did you really test this on Android?
Sorry if I doubt this.
Greetings
Markus
|
|
|
|
Posts:
401
Registered:
4/13/09
|
|
Am 06.03.2017 um 20:23 schrieb steven chesser:
Hello,
given Delphi Berlin and a TEdit. I like to detect when the user presses Enter.
I implemented a OnTyping event already where I loop through all the chars of the .Text.
If vkLineFeed or vkReturn is detected it is Enter (vkLineFeed by finding out that certain devices
do send that one).
But now I encountered a device which simply closes the keyboard on enter but doesn't
send me a "enter" char. It's a LG L50 with Android 4.4.
Is there some method to reliably detect return presses on Android/FMX?
Greetings
Markus
Tried anything like this on the keyup event?
procedure TForm38.Edit1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
begin
if key = vkreturn then showmessage('vkReturn') else
if key = vkLineFeed then showmessage('vkLineFeed') else
showmessage('Unknown : '+key.tostring);
end;
Only have a few devices to test with ... all returned vkReturn
Hello,
isn't ShowMessage a synchronous dialog?
If yes they won't work on Android as they're not allowed.
Did you really test this on Android?
Sorry if I doubt this.
Greetings
Markus
I tried it on 3 devices I have ... I guess I should have mentioned the keyup event only worked ON hitting the return key.. .did not happen pressing anything else..
so basically typed stuff... hit enter key on the android keyboard, would trigger the event.
|
|
|
|
Posts:
5,113
Registered:
11/9/03
|
|
Am 07.03.2017 um 04:27 schrieb steven chesser:
Am 06.03.2017 um 20:23 schrieb steven chesser:
Hello,
given Delphi Berlin and a TEdit. I like to detect when the user presses Enter.
I implemented a OnTyping event already where I loop through all the chars of the .Text.
If vkLineFeed or vkReturn is detected it is Enter (vkLineFeed by finding out that certain devices
do send that one).
But now I encountered a device which simply closes the keyboard on enter but doesn't
send me a "enter" char. It's a LG L50 with Android 4.4.
Is there some method to reliably detect return presses on Android/FMX?
Greetings
Markus
Tried anything like this on the keyup event?
procedure TForm38.Edit1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
begin
if key = vkreturn then showmessage('vkReturn') else
if key = vkLineFeed then showmessage('vkLineFeed') else
showmessage('Unknown : '+key.tostring);
end;
Only have a few devices to test with ... all returned vkReturn
Hello,
isn't ShowMessage a synchronous dialog?
If yes they won't work on Android as they're not allowed.
Did you really test this on Android?
Sorry if I doubt this.
Greetings
Markus
I tried it on 3 devices I have ... I guess I should have mentioned the keyup event only worked ON hitting the return key.. .did not happen pressing anything else..
so basically typed stuff... hit enter key on the android keyboard, would trigger the event.
Hello,
ah, that's a good hint!
Now I should retry using it. I guess I had something else in it first
and when this didn't fire I stopped using it.
Greetings
Markus
|
|
|
|
Posts:
5,113
Registered:
11/9/03
|
|
Am 07.03.2017 um 07:31 schrieb Markus Humm:
Am 07.03.2017 um 04:27 schrieb steven chesser:
Am 06.03.2017 um 20:23 schrieb steven chesser:
Hello,
given Delphi Berlin and a TEdit. I like to detect when the user presses Enter.
I implemented a OnTyping event already where I loop through all the chars of the .Text.
If vkLineFeed or vkReturn is detected it is Enter (vkLineFeed by finding out that certain devices
do send that one).
But now I encountered a device which simply closes the keyboard on enter but doesn't
send me a "enter" char. It's a LG L50 with Android 4.4.
Is there some method to reliably detect return presses on Android/FMX?
Greetings
Markus
Tried anything like this on the keyup event?
procedure TForm38.Edit1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
begin
if key = vkreturn then showmessage('vkReturn') else
if key = vkLineFeed then showmessage('vkLineFeed') else
showmessage('Unknown : '+key.tostring);
end;
Only have a few devices to test with ... all returned vkReturn
Hello,
isn't ShowMessage a synchronous dialog?
If yes they won't work on Android as they're not allowed.
Did you really test this on Android?
Sorry if I doubt this.
Greetings
Markus
I tried it on 3 devices I have ... I guess I should have mentioned the keyup event only worked ON hitting the return key.. .did not happen pressing anything else..
so basically typed stuff... hit enter key on the android keyboard, would trigger the event.
Hello,
ah, that's a good hint!
Now I should retry using it. I guess I had something else in it first
and when this didn't fire I stopped using it.
Greetings
Markus
Didn't work in my short test. I'll try out the solution mentioned by
Dave Nottage as soon as time permits.
Greetings
Markus
|
|
|
|
Posts:
1,850
Registered:
1/7/00
|
|
|
|
|
Posts:
5,113
Registered:
11/9/03
|
|
Am 06.03.2017 um 21:29 schrieb Dave Nottage (TeamB):
Hello,
if being used together with a TEdit (as intended by me) it works.
Thanks!
Greetings
Markus
|
|
|
|
Legend
|
|
Helpful Answer
(5 pts)
|
|
Correct Answer
(10 pts)
|
|
Connect with Us