views:

145

answers:

1

Is there a way to interfere between the blackberry keyboard input and the key events that reach the foreground application? i.e. what we want to do is build a predictive keyboard functionality to be used on any application that needs keyboard input (like textboxes, emails, etc.), so we need to: 1) get the keys that are pressed 2) present a couple of possible predictions on screen 3.a) the user picks the predicted word by clicking on it or 3.b) keeps writing

Is there a way to do this on Blackberry? I know we can listen to the keyboard, but I'm not sure whether we can show something on screen while another application is in the foreground, and how to tell the application to get the predicted word the user picked.

Thanks in advance!

A: 

I know we can listen to the keyboard,

This is the main problem... you see, in background application the only key event you can handle is Keypad.KEY_ESCAPE:
StackOverflow.com - BlackBerry - KeyListener with global scope
BlackBerry Technical - Developer Forum - KeyListener in Background
BlackBerry Development:Java Development:KeyListener in Background App

but I'm not sure whether we can show something on screen while another application is in the foreground,

You can show global dialog with suggestion words list:

private void showMessage(String message) {
    synchronized (Application.getEventLock()) {
        Dialog dlg = new Dialog(Dialog.D_OK, message, 
                        Dialog.OK, null, Manager.FIELD_HCENTER);
        Ui.getUiEngine()
                        .pushGlobalScreen(dlg, 1, UiEngine.GLOBAL_QUEUE);
    }
}

and how to tell the application to get the predicted word the user picked.

Can be achieved by event injections: BlackBerry - Simulate a KeyPress event

Max Gontar