Text input behaves not expected when text is from keyboard suggestions and when paused and resumed backspace not working and keyboard_suggestions not working

188 views
Skip to first unread message

Aravind R

unread,
Dec 3, 2022, 1:01:48 AM12/3/22
to Kivy users support
Hi Kivy support team,
          I am facing some issues on the MDTextfield. I do have some overrided functions on it to allow only alphabets. Though I haven't touched any backspace functions. I have attached a sample snippet and recording of how it behaves for words when it is copied from keyboard suggestions. Also If we set the keyboard_suggestions to False, it still shows the suggestions for words. Keyboard I have in android is default GBoard for android.
Issue #1:
Expected: When I type "ency" and keyboard suggestions show text "encyclopedia" and when I touch it and that word populated in text field and when I do backspace once it should erase last character 'a' and when I do backspace one more time it erase updated last character 'i'.

Actual: When I type "ency" and keyboard suggestions show text "encyclopedia" and when I touch it and that word populated in text field and when I do backspace once it is erasing nothing and when I do backspace one more time it shows text 'lopediaencyclopedi'.

Issue #2:
When I click on the button, it flips keyboard_suggestions to False/True, but it in both case keyboard shows word suggestions.

Issue #3:
When I pause the app to background and resume it, even the typed characters are ineffective when backspace is touched. Anyways Selecting all and doing backpace works and cut operation also works, but still that's the primary functionality expected.
 
Please correct me if I am wrong. Please help me resolving these issues. Is this a kivy core code issue or is it due to some of my doing ?
Screenrecording_20221203_110522.mp4
main.py

Elliot Garbus

unread,
Dec 3, 2022, 11:18:12 AM12/3/22
to kivy-...@googlegroups.com

Looks like at least part of this has been addressed in a recent update to p4a: https://github.com/kivy/python-for-android/pull/2692

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/131170b7-4d7c-47e4-9fb9-f09b0d89c2afn%40googlegroups.com.

 

Elliot Garbus

unread,
Dec 3, 2022, 11:29:53 AM12/3/22
to kivy-...@googlegroups.com

You may find using input_filter simpler that overloading insert_text.

Assuming you wanted to only allow letter inputs, you could do as below:

 

from kivymd.app import MDApp

from kivymd.uix.button import MDFlatButton

from kivymd.uix.floatlayout import MDFloatLayout

from kivymd.uix.textfield import MDTextField

 

 

class Word(MDTextField):

    def __init__(self, **kwargs):

        super().__init__(**kwargs)

        self.input_filter = self.letters_only

 

    def letters_only(self, substring, from_undo):

        if substring.isalpha():

            return substring

 

 

class TestTextFieldApp(MDApp):

    def btnOnRelease(self, instance):

        if (self.word.keyboard_suggestions):

            self.word.keyboard_suggestions = False

            self.btn.text = "Turn on keyboard suggestions"

        else:

            self.btn.text = "Turn off keyboard suggestions"

            self.word.keyboard_suggestions = True

 

    def build(self):

        self.root = MDFloatLayout()

        self.word = Word()

        self.word.input_type = "text"

        self.root.add_widget(self.word)

        self.word.pos_hint = {"center_x": 0.5, "center_y": 0.5}

        self.word.size_hint = (0.75, 0.125)

        self.btn = MDFlatButton()

        self.btn.text = "Turn off keyboard suggestions"

        self.btn.bind(on_release=self.btnOnRelease)

        self.btn.pos_hint = {"center_x": 0.5, "center_y": 0.4}

        self.btn.size_hint = (0.6, 0.125)

        self.root.add_widget(self.btn)

        return self.root

 

 

if __name__ == '__main__':

    TestTextFieldApp().run()

 

From: Aravind R
Sent: Friday, December 2, 2022 11:02 PM
To: Kivy users support
Subject: [kivy-users] Text input behaves not expected when text is fromkeyboard suggestions and when paused and resumed backspace not working andkeyboard_suggestions not working

 

Hi Kivy support team,

--

Toon to Tech

unread,
Dec 4, 2022, 12:32:58 AM12/4/22
to kivy-...@googlegroups.com
I see some discussions on the link you provided regarding these keyboard issues on backspace functionality and keyboard suggestions.

What are the issues I mentioned were handled as part of the commit ? 

Are the changes now available in master branch now ?

Maybe I will try a build with p4a.branch = develop and get back here. 

Toon to Tech

unread,
Dec 4, 2022, 11:24:59 PM12/4/22
to kivy-...@googlegroups.com
Hi Kivy Support team,
       I altered the bit of code as per the snippet you gave. It works like a charm. I ran the android build again with p4a.branch = develop in buildozer.spec file. Still I see some different issues here.
Issue #1: keyboard_suggestions flag not working
        I don't see the "keyboard_suggestions" flag seems to be working here in my case. Device : IQOO Z5 Pro, Android version : 12,Keyboard : GBoard.
Issue #2: Keyboard suggestion words not populated
        Now the suggested word is not getting populated in the text field. Also I observe a deviation in the keyboard suggestion behaviour. When I type 'test' and it shows 'testing' in suggestions and when I touch it, it won't populate 'testing' and still shows the word 'test' and when I touch backspace 4 times the word 'test' gone in text field but the keyboard suggestions still holds the word 'test' and on repeating backspace 4 times again removes that suggestion.

I have attached a sample snippet of code and some relevant files for reference. Please let me know how to resolve this. Is it an issue in kivy framework code or the issue is in user code ?. Please let me know if you need anything from my side :)
main.py
buildozer.spec
Screenrecording_20221205_091033.mp4

Elliot Garbus

unread,
Dec 5, 2022, 8:17:38 PM12/5/22
to kivy-...@googlegroups.com

Robert – do you have any idea here?

 

I suggest removing the input filter and testing this again to make sure there is not an issue with the input filter.  If the suggestion is trying to add a space, it will not be accepted by the filter.

Robert

unread,
Dec 5, 2022, 9:05:15 PM12/5/22
to Kivy users support
Sorry, I don't know anything about 'keyboard_suggestions'. So I have no idea if this is a usage issue, or a platform issue.

If it is a platform issue: A little searching shows this update was basically an SDL version bump, https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/bootstraps/sdl2/build/src/patches/SDLActivity.java.patch . The only person who is going to have any understanding of this part of the SDL api is @misl6 , and the place to contact him would be at the PR Elliot referenced.

Aravind R

unread,
Dec 6, 2022, 7:33:57 AM12/6/22
to Kivy users support
@Elliot It seems that when we select keyboard suggested word, it produces the word along with trailing space at the ending side of word. You are right. So I modified the substring with strip() function. But there's another issue with it. As per keyboard functionality, It still assumes that the word delivered was with a space and it was messing up.

Let me throw an example. Let us say I type string "tes" and the keyboard suggestions shows "test "(with trailing space at end only) and I touch the suggested word, now the word "test"(without a space) as strip is ised  was populated and when I do backspace 4 times the word in text field holds "" but as per keyboard functionality memory it holds "t" (as it still considers space) and shows another suggestion word say "thanks", the text field only receives the text "hanks" as the keyboard considers "t" was already there. This is one issue

Still the keyboard_suggestions flag switches has no effect on keyboard suggestions and it is always showing suggestions. I am blocked in either ways here as I want functionality for only alphabets to be populated.

I have attached the snippet script I used and a small recording demonstrating first issue. Please guide me for resolving this issue. If there's anything you need from my side, Please let me know :)
main.py
Screenrecording_20221206_174700.mp4

Elliot Garbus

unread,
Dec 6, 2022, 9:07:42 AM12/6/22
to kivy-...@googlegroups.com

I suggest you look back at the GitHub issue link.  If the solution at the link does not work – ask there.  I have not done any android programing. 

Toon to Tech

unread,
Dec 11, 2022, 7:21:33 AM12/11/22
to kivy-...@googlegroups.com
I hope these issues can still be resolved through some way in platform code of android programming.
So I reported the issue on github. Let's hope for a resolution soon.

Please find github links of the issues here.

Happy kivy coding :)

Reply all
Reply to author
Forward
0 new messages