John van de Waeter 7 Posted Sunday at 10:04 AM Hi All, Just noticed. The OnTyping event is fired differently depending on the Android version. I have a TEdit that is used for incremental text searching. The user types, I use the OnTyping event to read the text from the TEdit and use this text to scan a table for keywords. Works okay on Windows, Mac, iOS and Android 12 (Samsung Galaxy Tablet). On all targets, the Ontyping event is fired once for every typed character. On my Galaxy S21, Android 15, however, the event is fired again and again for the length of the typed text. So if I type 'tha' I should have 3 events. Edit.text = 't', edit.text='th' edit.text='tha'. On my Galaxy S21, Android 15, I get 6 events: type the t: 1 event fired: edit.text ='t' type the h: 2 events fired: edit.text='t', immeditaely followed by edit.text='th' type the a: 3 events fired: edit.text='t', edit.text='th', edit.text='tha'. So as many events as the length of the typed text. This continues until the user types a space. In that case only one event is fired and inside this event, edit.text equals the contents of the Tedit. As expected. My dev: Delphi 12.3, Android 25.2.5 both 32 and 64 bit Unfortunately I don't have more Android devices to test... Is this a problem in Android 15? tia, John Share this post Link to post
Olli73 7 Posted Sunday at 11:08 AM Have you tried another keyboard (gboard?) ? Share this post Link to post
John van de Waeter 7 Posted Sunday at 11:28 AM I just did, and another keyboard like this GBoard seems to work okay... However, it would be strange to tell my users to install another keyboard... Share this post Link to post
Olli73 7 Posted Sunday at 11:35 AM In the past, when I had issues with my Android apps, it happned nearly only on some Samsung devices; so I thought already that it is the Samsung keyboard... Samsung can everything, besides software 😉 Share this post Link to post
Olli73 7 Posted Sunday at 11:45 AM And the most strange issue I had with Samsung devices, was that when you copied a bulk of pictures to a windows device via USB, some pictures had the content of another picture. And we had links to such pictures in our database and the customer told us we are doing something wrong, showing the wrong pic. Difficult to find the issue... Share this post Link to post
John van de Waeter 7 Posted Sunday at 12:02 PM So you told them to buy another phone? Share this post Link to post
Olli73 7 Posted Sunday at 12:12 PM At least I could tell them that the issue is related to Samsung. For the picture issue there were only a workaround (when you had still the pictures on android device): Copying the issued pic to a new empty folder with android file app and then copy this to windows. I by myself avoid Samsung galaxys and recommend other phones to peaple who ask me. Share this post Link to post
John van de Waeter 7 Posted Sunday at 12:29 PM Hmm... It's one of the most used android phones... anyway, I noticed on a friends' Galaxy/Android 13 the TEdit with the OnTyping event has issues as well... Time to figure out just another workaround... Share this post Link to post
Olli73 7 Posted Sunday at 12:38 PM You could save the content of the edit in a variable and then first check if content has changed. And you could try if it makes a difference when you set the edit to "platform" or not. Share this post Link to post
John van de Waeter 7 Posted Sunday at 01:15 PM (edited) Yes, I know... thanks for thinking with me 🙂 Edited Sunday at 01:15 PM by John van de Waeter typo Share this post Link to post
John van de Waeter 7 Posted Monday at 07:49 AM The problem is that the events OnTyping , OnValidating , OnChangeTracking, OnKeyUp, OnKeydown ALL are fired as many times as there are characters in the EditBox. That is, on my Galaxy 21, Android 15. I could work around it if I would know how many characters are in the EditBox, like length(editbox.text), but inside the eventhandler, that number gives me 0,1,2,3,4,.. NOT the actual length of the contents of the editbox. Is there a way to access the underlying editbox, in which on screen I can clearly see e.g. 6 characters, that gives me a "6"? In that case I could count the number of events and know which one is the last one and act upon it. Share this post Link to post
Olli73 7 Posted Monday at 09:30 AM (edited) Makes it no difference if you use platform or fmx edit? Other solution: 😉 https://giphy.com/gifs/reactionseditor-reaction-3o7btNRTJ700Vzmn5e Edited Monday at 09:30 AM by Olli73 Share this post Link to post
John van de Waeter 7 Posted Monday at 09:34 AM 3 minutes ago, Olli73 said: Makes it no difference if you use platform or fmx edit? Nope. Platform style doesn't fire the OnTyping event. Share this post Link to post
Brian Evans 128 Posted Monday at 12:11 PM 4 hours ago, John van de Waeter said: The problem is that the events OnTyping , OnValidating , OnChangeTracking, OnKeyUp, OnKeydown ALL are fired as many times as there are characters in the EditBox. That is, on my Galaxy 21, Android 15. I could work around it if I would know how many characters are in the EditBox, like length(editbox.text), but inside the eventhandler, that number gives me 0,1,2,3,4,.. NOT the actual length of the contents of the editbox. Is there a way to access the underlying editbox, in which on screen I can clearly see e.g. 6 characters, that gives me a "6"? In that case I could count the number of events and know which one is the last one and act upon it. That sounds like the OS/keyboard is retyping content into the edit control. The edit does go back to being empty and then having 1,2,3 etc characters in it just within a short period of time. One thought: keep track of the last partial search string and start/reset a short timer in the OnXXX events. When the timer event triggers check if the edit content is not equal to what was last searched for and update the search as appropriate. This gives time for the OS/keyboard to be done changing the edit contents before you use it's contents in your search. Share this post Link to post
John van de Waeter 7 Posted Monday at 02:32 PM 2 hours ago, Brian Evans said: That sounds like the OS/keyboard is retyping content into the edit control. The edit does go back to being empty and then having 1,2,3 etc characters in it just within a short period of time. Yes, it looks somewhat in that direction, given the fact that another keyboard (GBoard) does not have the problem. 2 hours ago, Brian Evans said: One thought: keep track of the last partial search string and start/reset a short timer in the OnXXX events. When the timer event triggers check if the edit content is not equal to what was last searched for and update the search as appropriate. This gives time for the OS/keyboard to be done changing the edit contents before you use it's contents in your search. Yes, I made something similar. Not using the events ,nor a timer, but polling the text from the editbox in the app's OnIdle event. Kinda dirty, but it works :) Share this post Link to post