Search code examples
blackberrykeyboardblackberry-torch

Input data into BasicEditField on BlackBerry Torch


I'm writing an app which has a function asking users to type a filename into a BasicEditField on a PopupScreen. The app works fine with Blackberry Storm 2 -- both the simulator and a real device.

The problem is that the app doesn't work on a BlackBerry Torch -- neither the simulator nor a device. I can't enter text into the BasicEditField.

Why doesn't the keyboard on the BlackBerry Torch work with a BasicEditField? I've also tried an EditField instead of BasicEditField but it doesn't work either.

private BasicEditField txtFileName = 
    new BasicEditField("Name: ", "", 50, EditField.EDITABLE | EditField.FILTER_FILENAME);
...
Constructor()  
{  
    add(txtFileName);  
}

Solution

  • OK, the mistake I made was to put the wrong return value for the keyChar method.
    I put
    return true;
    at the end of the method,
    which should be
    return super.keyChar(key,status,time);
    Below is the correct implementation for the keyChar method:

    public boolean keyChar(char key, int status, int time)
    {
        ..................
        /*
        return true; // user cannot type in the BasicField on Torch, but can type on Storm
        */
        return super.keyChar(key,status,time);// works on both Torch and Storm
    }