Delphi XE5 android app keydown and keyup events - android

I want the keydown (or up) event for an edit-box so I can do a database lookup for the text entered so far. This works fine in Windows, but on Android only the Enter is send.
Does anyone know how to capture the key-events in XE5 of the virtual keyboard?

I don't think that detecting keyboard events was ever the right way to solve this problem. That's because there are many ways of getting text into a control, and not all of them involved pressing keys. You are really trying to detect when the text of the edit control changes. For that you simply listen to the OnChangeTracking event.

Related

Simulate the winKey press event in android

I'm using a bluetooth keyboard with an android tablet and i've found that there's some shortcut avaible from a qwerty keyboard. I want to generate some of them from the code. I'm able to trigger the majority of all the key combination but I'm not able to trigger a winKey (The windows logo key on a qwerty). I've basically try every KEY CODE from android and non of them want to work.
If any one as a little hint on that subject that would be appreciated.

Delphi XE5 Firemonkey TStringGrid OnClick event

I have a very strange problem with Delphi Firemonkey TStringGrid on Android. It looks like that events on TStringGrid are triggered differently on windows and android platform.
For example: in windows firemonkey application I have a string grid with a few columns. TStringGrid is set as read only. OnClick event I have the following code:
TStringGrid(Sender).Cells[TStringGrid(Sender).ColumnIndex,TStringGrid(Sender).Selected] := 'result';
Android application has exactley the same code OnClick event
TStringGrid(Sender).Cells[TStringGrid(Sender).ColumnIndex, TStringGrid(Sender).Selected] := 'result';
When I run windows application and click on string grid cell it becomes selected and then ‘result’ is written in the cell.
windows before click
windows after click
When I run android application and do click (tap) what happens is that ‘result’ is written in previously selected cell, and after that cell where I did click becomes selected.
android before click
android after click
I am not sure is this a bug in Firemonkey or expected behavior. Is there a way to overcome this?
TGrid is not a supported control on mobile so you should avoid using it. The best alternative is probably a TListBox with a custom style.
It might a threading issue. But I'm not so sure you are using the best event handler. If you are trying to update the cell that is being selected, then I would advice you handle the TStringGrid.OnSelChanged event. This event is fired after cell selection has been changed.
Beware though... it is not strictly fired by mouse clicks (or finger taps). If you have some sort of keyboard attached to the Android device, or on a desktop platform, it will also fire when you use arrow keys and other means. I think you get what I mean... but then maybe that is just what you are looking for.

Simulating arrow key presses in android

I am currently working on an app that simulates the d-pad (up, down, left, and right). The problem is that I can't figure out how to send those key presses to other applications.
Currently, I am using Instrumentation and it works perfectly fine in the activity of my app.
Here is the snippet of the arrow key left code:
new Thread(new Runnable() {
#Override
public void run() {
new Instrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_LEFT);
}
}).start();
The problem with this implementation is that due to an android security feature, I cannot send key presses to other applications.
After searching up different ways to injecting key presses, I came across this article. However, after trying the example code, it doesn't seem to work. I poked around and found out that android doesn't seem to have an input device for the keyboard. When I scan for different input devices, I get stuff such as orientation sensor and etc. Here is a pic of all the input devices on my phone (T-959 Galaxy S).
As you can see, none of these devices is a keyboard. I have a feeling that this is because my phone does not have a physical keyboard. (cypress is the capacitive keys, aries is the volume buttons, and mxt224 is the touchscreen controller)
After a bit more of research, I found that the accessibility api in android has limit capabilities for injecting events, but those are only very basic things such as switching view focus and etc (AccessibilityNodeInfo). However, I have a feeling that I might be able to extend it to support arrow key presses.
So currently, I am very confused on where to go. Has anyone ever done anything like this before? It seems that the simple injection of arrow keys (nothing else) is very frustrating due to the security features in Android. All suggestions are welcomed.
EDIT: I might not have been very clear, but I am fine with building this for rooted phones only. Only requirement is that this app has to run standalone on the phone without being hooked up to any external keyboards via otg or the computer via adb.
I wanted to simulate DPAD key press events few days back and I did find a solution which has its own limitation.
Arrow key press can be simulated using adb commandinput keyevent <keycode>.
So if you want to simulate a DPAD LEFT key press then use the adb commandadb input keyevent 21.
To reuse this bit of code and scale it forward, I created a standalone swing application where i select the device to which i need to send the key events and I can use the existing keyboard of my computer to type in the keys.[I map the keyboard key codes to android key codes].
I am further scaling the application by including remote and game pad buttons, once done, i'll upload the project on git.
Hope this helps.
IF you intention is to create an application that works on non rooted phones perhaps your best bet is to implement a new InputMethod using http://developer.android.com/reference/android/inputmethodservice/InputMethodService.html

Trigger onFocus textBox Android gwt webapp phonegap 1.1

I'm running a webapp on Android galaxytab.
I have 3 textbox with FocusHandler-s erasing the textbox content onFocus.
This works well but if the user uses the tab, previous or next buttons on the device's keyboard, the FocusEvent is not triggered.
I tried to catch Key events to prevent default action on TAB but the tab key is not triggerd either.
Does anyone know how to trigger a FocusEvent on tab or previous/next key press on an Android device keyboard? (Everything works well in computer's browser even if using tab key the focus event is triggered but not in Android's browser).
While this isn't a fix for your FocusHandler issue, if the content in the textbox that is being erased is a placeholder, perhaps you can benefit from this answer.
Take a look at http://www.m-gwt.com
The library provides placeholders for input elements in gwt.

Android: How to intercept keydown globally (on hardware keyboard)

Is there a possibility for an android app to run as a service in the background, intercept keydown events from the hardware keyboard and change behavior (i.e. the resulting character) in some special cases?
The idea in mind is to have sort of a keyboard layout fix, mainly making important special characters available using an alternative keymap instead of having to select from a huge grid on the touch screen. Sometimes, the default keymap of a mobile devices do not represent all important characters, even more when it comes to non-english languages.
Thanks for inspiration :)
Peter
EDIT: additionally emphasized hardware
What you are describing is in fact not a service in background but replacing the keyboard app itself..take a look at the SWype app.
You do not have to create a service to do this as you want just the your own keyboard layout coming up when entering text, etc.
The sample of replacing a default app in the sdk is the homescreen but the keyboard app can be replaced as well..

Categories

Resources