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

set focus ¿?

What can I do for  when entry a new screen of my application, the focus is on a specific container without moving the wheel? thanks!

 

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: set focus ¿?

use the setFocus method. you could call it on onDisplay for example
----------------------------------------------------------
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
Posts: 171
Registered: ‎03-04-2009
My Device: Not Specified

Re: set focus ¿?

I get this error with setFocus(): "setFocus called on a field that is not attached to a screen" . My code:

 

public HojaInformativaScreen(CRMBBController controller){
		
		this.controller = controller;
		ClienteDTO cliente = controller.getClienteActual();
		
		//Cabecera
		setTitle( new LabelField(resources.getString(CRMBBLangResource.HOJA_INFOR), Field.FIELD_HCENTER));
		

		// Asignamos el tamaño de la fuente dependiendo 
		// del ancho de la pantalla
		//int tam = controller.getTamañoScreen();
		Font fuenteBold = Fuente.getFuenteBold();
		Font fuentePlain = Fuente.getFuentePlain();
		
		setFont(fuentePlain);
		
		manager = new RoundRectVerticalManager();
		
		//cabecera
		cabecera = HojaResumenClienteScreen.getCabeceraCliente(cliente);

		int tamBut = 195;
		
		if (Display.getWidth() > 240){
			
			tamBut = 395;
		}
		
		b1 = new WidthButtonField(resources.getString(CRMBBLangResource.ORG_DIREC), 0, tamBut);
		b1.setFocus();
		b2 = new WidthButtonField(resources.getString(CRMBBLangResource.PERS_CONTAC), Field.FIELD_TOP, tamBut);
		b3 = new WidthButtonField(resources.getString(CRMBBLangResource.FINAN_CRED), Field.FIELD_TOP, tamBut);
		b4 = new WidthButtonField(resources.getString(CRMBBLangResource.TITULO_ULT_DOC_COMER), Field.FIELD_TOP, tamBut);
		b5 = new WidthButtonField(resources.getString(CRMBBLangResource.ULT_ACT), Field.FIELD_TOP, tamBut);
		b6 = new WidthButtonField(resources.getString(CRMBBLangResource.PRODUCTOS), Field.FIELD_TOP, tamBut);
		b7 = new WidthButtonField(resources.getString(CRMBBLangResource.ENVASES), Field.FIELD_TOP, tamBut);
		b8 = new WidthButtonField(resources.getString(CRMBBLangResource.ESTADIST), Field.FIELD_TOP, tamBut);
		
		HorizontalFieldManager h1 = new HorizontalFieldManager();
		VerticalFieldManager listaBotones = new VerticalFieldManager();
		h1.add(listaBotones);

		
		listaBotones.add(b1);
		listaBotones.add(b2);
		listaBotones.add(b3);
		listaBotones.add(b4);
		listaBotones.add(b5);
		listaBotones.add(b6);
		listaBotones.add(b7);
		listaBotones.add(b8);
		
		manager.add(cabecera);
		manager.add(h1);
		
		add(manager);
	}

 

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: set focus ¿?

move it to the end of your code. or call it on onDisplayed
----------------------------------------------------------
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
Posts: 171
Registered: ‎03-04-2009
My Device: Not Specified

Re: set focus ¿?

thanks you very much!!!

Regular Visitor
Posts: 1
Registered: ‎10-26-2011
My Device: Developer
My Carrier: Bold 9780

Re: set focus ¿?

Thanks so much !!!