Before upgrading my nexus 4 from Android 4.3 to 4.4(Kitkat) i could erase whith the BackSpace button a default text that i was casting on load in a TextInput. Strangely, now i cannot delete the text of this TextInput while using the default keyboard (the Google keyboard), but works perfectly with other keyboards that are available on Google Play. I don't know if it is an OS issue or my code needs modification or an upgrade to Kivy might be required.
my code looks as follows (in kv):
TextInput:
id:txt_from_mail
font_size: root.height * .044
size_hint: (None,None)
size: root.width*.65,root.height*.0833
background_color:(1,2,0.7,0.9)
foreground_color: (.2,.4,.5,.9)
padding_y:self.height*.12
text:"YourGmail#gmail.com" # this is the text that i cannot delete or modify
multiline:False
on_focus:root.clear_mail_feedback()
and in Python the function looks like that:
def clear_mail_feedback(self):
self.the_mail_feedback.text="" # this is a label in my form that gives text feedback to users
EDIT : i can also add other findings. typing text in the TextInput, put the application in the background, call back the application, and try to edit your text, you cannot! could it be an issue with latinIME? with native coding??? clueless...
This is a known issue with kitkat, kivy. There is a temp hack/fix here
Related
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, i.e. 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().
I am trying to use Odoo with the application Barcode & QR code Keyboard, from Nikola Antonov (just an example, I do not know if there are better options), in order to read barcodes for the pickings.
The first problem I had to face was I had to show the keyboard in this picking view
So I needed to create an input field in order to click in it and show the Android Keyboard, or in this case the Nikola Antonov keyboard. Then, I had to assign the function handler to this input text field:
this.$('#input_text_barcodes').on('keyup', self.getParent().barcode_scanner.handler);
The function is only working as expected if I use the normal Android Keyboard (AOSP) and only with numbers. The letters of the Android Keyboard or whatever character of the Nikola Antonov Keyboard are not working (only the backspace)
this.handler = function(e){
self.$('#aux_label').text('>> CODE: ' + e.which)
self.$('#aux_label').text('>> KEY CODE: ' + e.keyCode)
self.$('#aux_label').text('>> KEY: ' + e.key)
// [...]
I tried switching the languages of the keyboard as well, but with the same result
Should I change the keyup event?
Is there other way to catch the characters?
Finally I have asked to the developer of the application directly and he solved the problem quite fast. He made it work with numeric keys, that is enough for what I wanted to achieve.
I'm using Cordova 3.6.4 in Visual Studio 2013 Community Update 4 to build an apps with a "chat" functionality, the main reason that I use this technology is because I want to, hopefully, write once and can use it in all platforms such as Android phones, iPhones, all mobile phone browsers, all desktop browsers.
In order to let the users inputting the "message" to be sent, I create a [div] which is contenteditable="true" at the bottom left of the html, at the right hand side of this [div], I have two [image buttons], one is the [happy face] button, the other is the [send button]. (You know, just like Whatsapp, Line and WeChat!)
At any time the user can click the [happy face] button to select one of the many "face image" to insert into the cursor at the [div], then I'll add the html codes into the [div], e.g. div.innerHTML += '< img src="1.jpg">'
So, the innerHTML of this [div] can contain characters AND images, e.g.
12< img src="1.jpg" />34< img src="2.jpg" />
Of course, the actual display is:
12[1st Picture]34[2nd Picture]
If the cursor is at the end of this [div], and I clicked the [BACKSPACE], I expect the [2nd Picture] will be removed, if I clicked the [BACKSPACE] again, I expect the letter [4] will be removed from the [div], this is work at ALMOST every platform I mentioned including all mobile browsers in android and iphone/ipad, all desktop browsers. But it does not work when I build an Android app and run it in any Android phone.
Running it as a WebView in android phone, when I click the the [BACKSPACE], the letter [4] is removed instead of the [2nd Picture], when I click the [BACKSPACE] again, the letter[3] is removed. I can NEVER remove the 2 images no matter which IME I'm using.
To work around, I tried to add a keyup/keydown/keypress listener to the [BACKSPACE] but it never fires.
At last, to work around this [BUG], I need to add a third [X] image button and use JavaScript string.replace to remove the < img> tag when users click this [X] button, but it looks very stupid to the users!
It makes me crazy that ALL IMEs do not remove the image for me by pressing the [BACKSPACE], and if the key events are not fired, I cannot remove the images myself!
I tried ALMOST, I think, ALL the suggestions provided by stackoverflow but they don't work at all, either not applicable to CORDOVA, or with compilation error such as [command failed with exit code 8] in Visual Studio.
What should I do?
System: Qt/QML 5.3.1 Android with Windows QtCreator
Device: Samsung Tab 3 8", with Android 4.1.2
EDIT:
My Main QML page contains a TextInput with Keys.onPressed. This TextInput receives only the DEL key and not other keys from standard virtual keyboard.
How to do to receive all keys in the TextInput/Keys.onPressed event handler?
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
ApplicationWindow {
visible: true
width: 640
height: 400
toolBar: ToolBar {
Row {
anchors.fill: parent
ToolButton {
text: "Exit"
onClicked: Qt.quit();
}
}
}
TextInput {
width: 200
height: 40
focus: true
Keys.onPressed: {
console.log("Key="+event.key+" "+event.text);
}
Keys.onReleased: {
console.log("Key="+event.key+" "+event.text);
}
}
}
An error is raised by Qt when I'm pressing a key on virtual keyboard, including the DEL key:
W/Qt (26304): kernel\qmetaobject.cpp:1458 (static bool QMetaObject::invokeMethod(QObject*, const char*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument)): QMetaObject::invokeMethod: No such method QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery,QVariant)
EDIT (27.10.2014):
This problem occurs because it is a missing functionality in Qt/Qml, see the following link for discussion about it http://qt-project.org/forums/viewthread/45072/ and the following link for the report to Qt https://bugreports.qt-project.org/browse/QTBUG-40803
Analysis
As the question author already found, this problem is due to missing functionality in Qt for Android (see QTBUG-40803):
On Samsung devices, like tablets and smartphones, it is impossible to receive keys from the virtual keyboard [from a TextInput component], by using Keys.onPressed or Keys.onRelease, except for DEL and ENTER keys.
The issue is not limited to Samsung devices as told in the bug report; it's also happening on my Asus Nexus 7, for example. The DEL key mentioned in the bug report is the key ⌫ (Delete / Backspace) of the Android keyboard, not Delete (which the Android keyboard does not have). The key events for this key are not emitted every time, but only when pressed in an empty TextField.
This behavior is different from Qt desktop applications, where every keypress / key release event of a physical key is signaled by TextInput.
Solution
You cannot listen to Keys.onPressed / Keys.onReleased, but you can listen to the onTextEdited and onTextChanged signals of TextInput. For simple cases like to enable a button when the field contains text, these signals are enough. For other cases, you could analyze what text was typed and take action based on the key used for that.
This solution is further complicated by two other bugs:
On the Android platform, the textChanged() and textEdited() signals are not emitted by TextInput as long as predictive text input is enabled for the Android keyboard (source). I suppose they are emitted eventually but only after "committing" a word by typing the space character or tapping on a suggestion. That does not help if you want to react to key presses, of course. So you first have to disable predictive text input behavior with TextInput { inputMethodHints: Qt.ImhNoPredictiveText }.
On some devices, TextInput { inputMethodHints: Qt.ImhNoPredictiveText } has no effect (QTBUG-37533). Then, inputMethodHints: Qt.ImhSensitiveData is an alternative. Works on Asus 7. (This does not create a "password entry field" – text will still be shown in the field, but predictive input etc. is switched off.)
Taken together, a working solution (for me on Nexus 7) looks like this:
TextField {
inputMethodHints: Qt.ImhSensitiveData
onTextEdited: {
console.log("textEdited() signal received")
}
I have an address search field in my app. When this field gets focus I want to open the keyboard as in the following image.
It works fine for iOS when the keyboard type is set to Titanium.UI.KEYBOARD_NUMBERS_PUNCTUATION as in the following code
var search = Titanium.UI.createSearchBar({
barColor:'#c8c8c8',
autocorrect:true,
hintText:'enter address',
height:'43dp',
top:'75dp',
autocapitalization: Titanium.UI.TEXT_AUTOCAPITALIZATION_WORDS,
keyboardType:Titanium.UI.KEYBOARD_NUMBERS_PUNCTUATION
});
However on Android it appears as in the following image.
I am using Titanium mobile SDK 1.7.5
You should probably add :
softKeyboardOnFocus : Titanium.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS
Unfortunately, it may be overridden by the system. Try it on another Android system (3.0 for example) if the problem persist.