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

New Developer
Posts: 27
Registered: ‎08-26-2008
My Device: Not Specified

How to set EditField focusable or non-focusable when running?

[ Edited ]

I know i could set EditField focusable or non-focusable in its Constructor by setting the style.


But I want to set it focusable or non-focusable when running like setEditable(boolean editable). How could i do that?


I try to use new Constructor with focusable or non-focusable style . But it doesn't work.


It seems after the variable is added to the screen. It cannot be set focusable or -non-focusable again.

Message Edited by mrmarkwang on 09-06-2008 06:25 PM
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to set EditField focusable or non-focusable when running?

Correct, for the standard Rim class, once set in the Constructor, it is fixed for life of the supplied EditField..


You have two choices:

1) Create a new EditField with the Style you want, and replace the incorrect one in the Manager with the correct one.

2) Override the isFocusable() method, like the following:

public class MyEditField extends EditField { private boolean _focusableFlag; public MyEditField(String label, String initial) { super(label, initial); } public boolean isFocusable() { return _focusableFlag; } public void setFocusable(boolean focusable) { _focusableFlag = focusable; } }