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
colombus
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified
Accepted Solution

Listfield Highlighter issue in 5.0 OS

Hi 

I am creating a listfield to draw a menu screen. Each row has an image and on highlightiing another image needs to be shown.

I commented the code in drawFocus () and in drawListRow() I tried if(selectedindex==getcurrentIndex && listfield.isFocus) { drawHighlighter image} 

else draw without highlighter.

This code is working perfectly in OS 6.0 Bt when I try it in 5.0 The hightlighter is not shown.

Then I tried if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) & uncommented super.drawFocus. Then the problwem is the blue highlighter is also shown along with List highlighter. How to solve this. Is there any workaround for this ??

Please use plain text.
Developer
colombus
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified

Re: Listfield Highlighter issue in 5.0 OS

Any suggestions on this

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Listfield Highlighter issue in 5.0 OS

This code should work:

 if(selectedindex==listfieldgetSelectedIndex() && listfield.isFocus()) ...

 

However I think I have had problems with this part of the test:

listfield.isFocus()

 

and ended up overriding onFocus and onUnfocus to set a flag I tested myself. 

 

So check which of the two parts of your if statement actually cause the drawListRow to bypass the highlighter and let us know. 

Please use plain text.
Contributor
herahadi
Posts: 27
Registered: ‎02-20-2013
My Device: 9900
My Carrier: Telkomsel

Re: Listfield Highlighter issue in 5.0 OS

i had the same issue.. here is the solution.

 

.isFocus is not working on blackberry OS 5, anyway its working good on os 6 and 7.

 

you should overide onFocus and onUnFocus.. below are the snippet code..

 

protected void onFocus(int direction) { _inFocus = true; super.onFocus(direction);}
	protected void onUnfocus() { _inFocus = false; super.onUnfocus(); } 

 now you can check wheter the listfield is focused or not by calling _inFocus boolean like bellow

if(_inFocus){
		Dialog.alert("focused");		
}else{ Dialog.alert("Silahkan pilih 1 rekening yang ingin Anda hapus."); }

 

Please use plain text.