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
ashutoshg
Posts: 140
Registered: ‎02-05-2009
My Device: 8900
My Carrier: Airtel India
Accepted Solution

How to make a field NON_FOCUSABLE at run time

Hi All,

 

Please help me out.

 

I have to change the property of a field at run time depending upon the input value of other field.

Assume that .... we have 5 BasicEditField in a mainScreen, if i enter 100 in 1st basicEditField, 2nd and 3rd basicEditField would get disable(NON_FOCUABLE).

I am using:

public void fieldChanged(Field field, int context) {

if(value of basicEditField1 == 100)

{

basicEditField2.setEditable(false);  

basicEditField3.setEditable(false);   

}

} /// this code sets the property of
basicedit field noneditable. but still these fileds are getting focus. 

i don't want this focus on these fileds.

 

Please help me out. how can i set the property of basiceditfield as NON_FOCUSABLE.

 

Thanks n Regads,

Ashutosh

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to make a field NON_FOCUSABLE at run time

you can overwrite the field to fit your needs. or you can exchange the field with a new one that has the desired style.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
ashutoshg
Posts: 140
Registered: ‎02-05-2009
My Device: 8900
My Carrier: Airtel India

Re: How to make a field NON_FOCUSABLE at run time

Thanks for this concept.I can apply this concept also.

But i think, this is huge process, if i have more than 50 fileds in a mainScreen.it also consume memory a lot to do so.

 

Please anybody can share any other concept.

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to make a field NON_FOCUSABLE at run time

there is no method to change the style of the field programatically.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: How to make a field NON_FOCUSABLE at run time

Why don't you delete the field using MainScreen.delete(field) when you don't need that field anymore .. You can add that again, if you need, using MainScreen.add(field) ..
--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Please use plain text.
Developer
ashutoshg
Posts: 140
Registered: ‎02-05-2009
My Device: 8900
My Carrier: Airtel India

Re: How to make a field NON_FOCUSABLE at run time

Thanks for this post.

I don't want to delete these field actully only want to do NON_FOCUSABLE.

 

Please use plain text.
Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: How to make a field NON_FOCUSABLE at run time

As far as this thing is concerned, RIM has not exposed a method called setFocousable(boolean) like setEditable(boolean).. And there is no way to get this done by even extending and creating a Custom Field..

 

Thanks, 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Please use plain text.
Developer
ashutoshg
Posts: 140
Registered: ‎02-05-2009
My Device: 8900
My Carrier: Airtel India

Re: How to make a field NON_FOCUSABLE at run time

yes, i think i need to make a custom components for all field.
Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to make a field NON_FOCUSABLE at run time

Here is some code that might help:

 

public boolean isFocusable() { return this.isEditable(); }

 

Please use plain text.
Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: How to make a field NON_FOCUSABLE at run time

[ Edited ]

Original:

Even if it is your custom component, you cannot set the property to NON_FOCUSABLE on the fly .. The workaround for this situation is you have to replace the field ..

 

Edited:

Yes, Peter's pretty solution works.. I thought of that but left since I assumed that isFocusable only retun true if it is focusable and making it return false will not change the property of the component.. I should've tried.. :smileytongue:

 

[Note: Peter and Me wrote the reply at the same time I guess.. I saw peter's reply only after I posted this reply..]

 

Thanks 

 

Message Edited by mantaker on 03-30-2009 03:26 PM
--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Please use plain text.