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
zaratustraelimp
Posts: 171
Registered: ‎03-04-2009
My Device: Not Specified
Accepted Solution

Disable screen elements ??¿¿

Hi, I have a problem. I want to when I select an item from a objectChoiceField of my screen, two objectChoiceField be disabled (not focusable or removed from the screen). I write this code in FieldChanged but does not work, I can do? thanks

 

...
ObjectChoiceField motivoInput = new ObjectChoiceField(null, motivos, 0, ObjectChoiceField.EDITABLE);
ObjectChoiceField situacionInput = new ObjectChoiceField(null, choiceSituacion, 0, ObjectChoiceField.EDITABLE);
...	
public void fieldChanged(Field field, int eventType) {
		
		if(field == tipoVisitaInput){
			int indice = tipoVisitaInput.getSelectedIndex();
			ZssdTipoVi auxTipoVis = (ZssdTipoVi) tipoVisitaInput.getChoice(indice);
			String idCurso = auxTipoVis.getTipoVisit();
			
			if(idCurso.equalsIgnoreCase("CU")){
				motivoInput = null;
				situacionInput = null
				
			}
		}
}

 


Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Disable screen elements ??¿¿

you could try to overwrite isFocusable or isEditable to return a custom value.
----------------------------------------------------------
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
Developer
zaratustraelimp
Posts: 171
Registered: ‎03-04-2009
My Device: Not Specified

Re: Disable screen elements ??¿¿

I have used this code and does not work

 

...

public void fieldChanged(Field field, int eventType) {
		
		if(field == tipoVisitaInput){
			int indice = tipoVisitaInput.getSelectedIndex();
			ZssdTipoVi auxTipoVis = (ZssdTipoVi) tipoVisitaInput.getChoice(indice);
			String idCurso = auxTipoVis.getTipoVisit();
			
			if(idCurso.equalsIgnoreCase("CU")){
				motivoInput.setEditable(false);
                                situacionInput.setEditable(false);
			}
		}
}

 


Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold

Re: Disable screen elements ??¿¿

I think this should work...

Can you run in debug mode and check if  these lines are executed...

 

motivoInput.setEditable(false);
                                situacionInput.setEditable(false);
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Disable screen elements ??¿¿

i suggested to overwrite functions, not to use setters.
----------------------------------------------------------
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
Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold

Re: Disable screen elements ??¿¿

Can i ask...if it is required just to disable a field in some action, why we should not use setEditable(false).

Developer
zaratustraelimp
Posts: 171
Registered: ‎03-04-2009
My Device: Not Specified

Re: Disable screen elements ??¿¿

You're right, this lines aren't executed. Now I can't change the objectChoiceField, thanks. And for non focusables? There aren't method setFocusable()...

Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold

Re: Disable screen elements ??¿¿

[ Edited ]

you can use

 

setVisualState(int visual)
visual - One of the following visual states: Field.VISUAL_STATE_NORMALField.VISUAL_STATE_ACTIVEField.VISUAL_STATE_FOCUS,Field.VISUAL_STATE_DISABLEDField.VISUAL_STATE_DISABLED_FOCUS.
Developer
zaratustraelimp
Posts: 171
Registered: ‎03-04-2009
My Device: Not Specified

Re: Disable screen elements ??¿¿

I can not use that method in a ObjectChoiceField, does not appear (I use 4.5.0 API)... :No:

Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold

Re: Disable screen elements ??¿¿

Yes true...it s available from 4.6.0

 

You can achive this either by removing the control from screen...

 

or 

replace this with a new NON_FOCUSABLE objectChoiceField