Blackberry custom EditField - handle focus

1.1k Views Asked by At

Something is driving me crazy on BlackBerry dev. I have a custom EditField. Here is the code:

private EditField m_Txt=new EditField(EditField.FOCUSABLE |
                                        EditField.FILTER_DEFAULT) {
    protected void layout(int width, int height)
    {
        setExtent(Display.getWidth(), m_TxtHeight);
    }
    public boolean isFocusable()
    {
        return true;
    }

    protected void onFocus(int direction)
    {
        super.onFocus(direction);
        invalidate();
    }

    protected void onUnfocus() {
        super.onUnfocus();
        invalidate();
    }
};

The thing is that it cannot get the focus. Actually it does call isFocusable etc. but the cursor doesn't show and I cannot write anything. I am surely missing something as I'm new to BlackBerry dev, but what ?

Thanks a lot

2

There are 2 best solutions below

0
On BEST ANSWER

I've actually found the answer. I totally forgot to call the super.layout method. So the layout method should be:

protected void layout(int width, int height)
{
    super.layout(Display.getWidth(), m_TxtHeight);
    setExtent(Display.getWidth(), m_TxtHeight);
}
0
On

What OS are you testing with? If it is a recent OS6 release, I've found in those versions you don't get a cursor in text edit fields until you enable select mode.