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
New Contributor
Posts: 2
Registered: ‎11-09-2012
My Device: Curve
My Carrier: Me

ObjectListField - highlighting a selection on click event

Hello,

 

I have a simple ObjectListField, on which I make a mutli-selection.

However, when I click on an item, I would like it to be highlighted to give confirmation to the user that the object is indeed selected. And same idea, when the user click angain on this item, the highlight must disappear (the selection is cancelled).

 

Here's a bit of my code, how can I set this highlighting on clik events?

list = new ObjectListField(ObjectListField.MULTI_SELECT){
			private int i;
			protected boolean navigationClick(int status,int time)
			{
				i = list.getSelectedIndex();
				String s = (String)bib.elementAt(i); //the String selected by the user
				if (!select.contains(s)){ // if the user hasn't selected this string yet, add to "select"
					select.addElement(s);
				}
				else{ //the user wants to cancel the selection
					select.removeElement(s);
				}
				return true;
			}

 

Thank you.

 

 

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

Re: ObjectListField - highlighting a selection on click event

welcome to the support forums.

i have never used multi selection. so take my comments with a grain of salt.
you can generally control the look of a single column by using the drawListRow method in the callback.
----------------------------------------------------------
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
New Contributor
Posts: 2
Registered: ‎11-09-2012
My Device: Curve
My Carrier: Me

Re: ObjectListField - highlighting a selection on click event

Thanks for your answer.

I tried to use drawListRow, but the method is called when any event happens, including keyUp and keyDown... and I would like it to happen on click event only (otherwise, just going down the list would highlight every line).

Any idea how I could proceed?

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

Re: ObjectListField - highlighting a selection on click event

the method is called every time a single row is painted.
you have to use logic to determine if the row is focused, selected etc.
----------------------------------------------------------
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