简体   繁体   中英

Bind Keyboard to TextInput while it is hidden on Android Kivy

I have created a simple kivy app which is successfully running on windows. It takes barcode of products as input and proceed further. I have designed my own keypad for my application + It takes input from Barcode Scanner as well (Scanned barcode is being placed in focused TextInput). For this, I have set

    Config.set('kivy', 'keyboard_mode', 'system')

which works perfectly fine.

Now, I want to run this app on android. On android, when a TextInput get's focus the android's keyboard becomes visible, which I don't want. I set TextInput property 'keyboard_mode' to 'managed' for this but it stops putting scanned barcode (from Barcode Scanner) in TextInput (as system keyboard will not be requested now).

What I want, hide the keyboard but it remain binded with focused TextInput, to access input from Barcode Scanner. I am stuck here, any help will be highly appreciated.

I am using: kivy==2.0.0, python==3.7.9 and buildozer to package application for android.

I have a few ideas but I first want to double check that you've put the Config.set('kivy', 'keyboard_mode', 'system') statement in the right place.

This needs to come before everything , ie the first two lines of your your main.py file should look like this:

from kivy.config import Config

Config.set('kivy', 'keyboard_mode', 'system')

from kivy.app import App
from kivy.core.window import Window

# etc.

The reason I ask this, is because writing Config.set() after importing App has no effect. On your computer I believe the default keyboard_mode is '' which is to simply choose the best option, which coincidentally is system . This can give the illusion of a working Config.set() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM