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
Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified
Accepted Solution

FOCUS ON CUSTOM LIST

I created a CustomListManger by extemding VerticalFieldManager. for the rows I created a CustomRow Manager by extending Mnager.

 

When I display the list I am not able to focus on the CustomRowManager that I have added. Focusable property is enabled for both CustomRowManager and CustomListManger .

 

Any help is welcomed!

Please use plain text.
Super Contributor
pp
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above
My Carrier: none

Re: FOCUS ON CUSTOM LIST

Hi avi_yach,
Manager cannot be made focusable... the fields in it can be focused.

if you want custom manager to be focusable then u have to do it in paint. on focus fillrect with some focus color.

i have used like this
boolean isFocusable = false;
protected void onFocus(int direction) {
isFocusable = true;
invalidate();
}

protected void onUnfocus() {
isFocusable = false;
invalidate();
}
protected void paint(Graphics graphics){
if(isFocusable) {
graphics.fillRect(0,0,getWidth(),getHeight());
//you can use bitmap image also
}
}
Thanks & Regards
pp
Please use plain text.
Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: FOCUS ON CUSTOM LIST

Hello pp, thanks a lot for your reply. the above code has helped me in performing a neat scroll, it is not working if in case I use

 

g.setBackGround(Color.BLUE);

 

 

A Y

Please use plain text.
Super Contributor
pp
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above
My Carrier: none

Re: FOCUS ON CUSTOM LIST

hi,
just use
g.setColorColor.BLUE);
before fill rect

Thanks & Regards
pp

Please use plain text.
Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: FOCUS ON CUSTOM LIST

Hello PP, that code worked great for focusing effect, but it didn't cater my other requirement to add fields to manager and I should also be able to fire an event when click is performed. 

 

From my understanding the method g.fillRect(0,0,Display.getWidth(),Display.getHeight()); is actually painting teh entire visible region of the manager.

 

I am following this thread as my reference for performing 

 

http://supportforums.blackberry.com/t5/Java-Development/Help-Focus-on-managers/m-p/1240859/highlight...

 

Regards, 

A Y

Please use plain text.
Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: FOCUS ON CUSTOM LIST

[ Edited ]

This is the look I am working on,

 

ParentManager extends VerticalFieldManager{}

MyMaanger extends Manager implements FocusChangeListener, FieldChangeListener
{
static int i = 0;
	NullField _focus = null;
	public MyManager(){
			i = i+1;
	        _focus = new NullField(NullField.FOCUSABLE|NullField.STATUS_MOVE_FOCUS_VERTICALLY);
	        _focus.setFocusListener(MyManager.this);
	        _focus.setChangeListener(MyManager.this);
	        this.add(_focus);
	        this.setChangeListener(MyManager.this);
	        this.add(new RichTextField("LIST COUNT "+i,RichTextField.NON_FOCUSABLE));
	
	}
	
	public void focusChanged(Field field, int eventType) {
		this.getManager().invalidate();
		int a = this.getFieldWithFocusIndex();
		int b = this.getFieldCount();
		Field _f = this.getFieldWithFocus();
		
	}
	
	
	
	protected void paintBackground(Graphics g) {
		  int prevBg = g.getBackgroundColor();
		  if (_focus.isFocus()) {
		    g.setBackgroundColor(Color.LIGHTBLUE);
		  } else {
		    g.setBackgroundColor(Color.WHITE);
		  }
		  g.clear();
		  g.setBackgroundColor(prevBg);
		}

	public void fieldChanged(Field field, int context) {
		UiApplication.getUiApplication().pushScreen(new Screen2());
	}


}

 This is the desired look, which is achieved, but no luck with clicklistener

 

 

9780.jpg

 

Please use plain text.
Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: FOCUS ON CUSTOM LIST

Please use plain text.