Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 171
Registered: ‎08-20-2008
My Device: Not Specified
Accepted Solution

EditField unresponsive

Hi All,

 

Have an issue when I add either a EditField, BasicEditField or an AutoTextEditField. I need to hold down the key to get any response even then the input is all in uppercase.

 

Cheers

 

        VerticalFieldManager searchVFM = new VerticalFieldManager(Manager.FIELD_HCENTER|Manager.FIELD_VCENTER);
        final AutoTextEditField SearchText = new AutoTextEditField();
        searchVFM.add(SearchText);
        ButtonField SubmitSearch = new ButtonField("Search");
        final submitButtonListener SubmitSearchListener = new submitButtonListener() {
            public void fieldChanged(Field field, int context) {
                if (SearchText.getText().length() < 3) {
                    Dialog.ask(Dialog.D_OK,"Search input must be at least 3 characters long");
                }
            }
        };
        SubmitSearch.setChangeListener(SubmitSearchListener);
        searchVFM.add(SubmitSearch);
        add(searchVFM);

BlackBerry Development Advisor
Posts: 15,017
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: EditField unresponsive

A FieldChangedListener is only changed when a field has changed.  If you want to capture characters as they are entered, you can override the keyChar method.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 171
Registered: ‎08-20-2008
My Device: Not Specified

Re: EditField unresponsive

Hi MSohm,

 

The FieldChangeListener is on the submit button I created below (I think?). I just included it for completeness. Don't want to do anything as fancy as capturing the characters as they are typed just a simple Google type one field one submit button type page. This TextField is added a to a custom class which extends the FullScreen class if that helps.

 

 

Cheers

Developer
Posts: 171
Registered: ‎08-20-2008
My Device: Not Specified

Re: EditField unresponsive

I Have found what seems to be causing the issue but not sure why. I have declared the two methods below in ready for implementing the KeyListener interface. If I scrub them it seems to work fine???

 

    public boolean keyChar(char key, int status, int time)
    {
        return false;
    }
    public boolean keyDown(int keycode, int time)
    {
        return false;
    }

BlackBerry Development Advisor
Posts: 15,017
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: EditField unresponsive

Overriding those methods allows you to provide custom key handling behaviour.  If you wish to use the default behaviour, they should not be overridden or should call super.keyChar/keyDown if you do.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 171
Registered: ‎08-20-2008
My Device: Not Specified

Re: EditField unresponsive

Cheers, that worked! Corrected the methods in the inherited class like below. Thanks very much :smileyhappy:

 

    public boolean keyChar(char key, int status, int time)
    {  
        return super.keyChar(key,status,time);
    }
    public boolean keyDown(int keycode, int time)
    {
        return super.keyDown(keycode,time);
    }