Symbian (and others?): How to translate "Q" into "1". Mapping char keys into numbers
My mobile app needs digit input only (some sort of a calculator) and I wouldn't like to bother the users with the need to switch to the digit input.
Is there some Qt way for converting the key code (raw scan code maybe?) into a digit that is on that key even if keyboard is not in a digit input mode right now.
On US/UK Symbian keyboard, for example, digit "1" shares key with the letter "Q", so I want to get 1 whenever user presses this key regardless of the input mode.
Well one solution might be to check if the user entered letter or number, after which check what the letter is and return the co-responding number. Put the letters in a map for example and check there
int number = m.key('Q');
I don't think there is any better solution to that, at least nothing Qt specific.
That would work, Eus, if I knew all the possible keyboard layouts for all the languages out there.
I'd like to have it a little more platform independent (or at least locale independent, for now it's fine if solution is Symbian-specific).
[quote author="artem.marchenko" date="1315150257"]That would work, Eus, if I knew all the possible keyboard layouts for all the languages out there.
I'd like to have it a little more platform independent (or at least locale independent, for now it's fine if solution is Symbian-specific).[/quote]
The best option is to set your editor to numeric mode on initialization itself. This way user won't have to change it.
QtK, problem is that I don't use any editors. 95% of app is QML with my own controls with controls similar to these onces + a couple of buttons http://store.ovi.com/content/135126
I draw on-screen keyboard for touch devices myself. For devices that also has hardware keyboard I use Keys element to listen to keyboard events ( http://doc.qt.nokia.com/4.7-snapshot/qml-keys.html ).
So I'd probably need to some system-wide way to switch input mode to digits (ok, app-wide, not system-wide). I am not sure if it is possible at all.
Hm.... Well you could always capture key events, not sure how that would work with QML, sorrry =/
I guess that the keys numeric values would be the same on all platforms with few differences at most, so that's the other thing you could check.
I don't mind capturing keys on the c++ side and then signaling them to QML, I just don't know how to translate the Q key scan code to whatever number lives on the same key.
Well, for latin alphabet letter-number mapping is quite stable for full QWERTY keyboards and non-QWERTYs are not common. For non-latin alphabets it won't probably work, however.
In the documentation about key scancode management you can find a useful example on how to manage keypressed under QML documents.