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

Native Development

Reply
Developer
greenback
Posts: 535
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

ListItemComponent onSelected background temporary feedback

wat property do you change on an individual list item component to change it's background color when it is selected (aka touched) before an action is triggered by the selection?

 

 

New Contributor
llornkcor
Posts: 5
Registered: ‎11-06-2012
My Device: bb10

Re: ListItemComponent onSelected background temporary feedback

This must be a common problem, as I am facing this as well.

 

Either its a bug, or there is no clear documented way of using a ListItemComponent and having a nice selected background or font change to indicate user has selected or activated the item.

Senior Software Engineer QtSensor, QSensorGestures qt-project
llornkcor technologies
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: ListItemComponent onSelected background temporary feedback

ListItemComponent is nothing by itself. It needs content. So you would have to set the background on the content you supply. Using standardlistitem is probably different but listitemcomponent itself isnt really UI related, in a sense.
Like all of my posts
Developer
jmoukel
Posts: 111
Registered: ‎07-05-2012
My Device: none

Re: ListItemComponent onSelected background temporary feedback

[ Edited ]

Hi guys,

 

I just went through this. And I managed to solve it this way in QML:

 

ListView
{
...

    listItemComponents: 
    [
         ListItemComponent 
         {
              type: "simpleItem"
              Container
              {
                  id: itemRoot
                  ...

                  onTouch: 
                     {		                     
	                   if(event.touchType == TouchType.Down)
                           {
                                  // Item was touched
		                   itemRoot.background = Color.Red
	                   }
                           else if (event.touchType == TouchType.Up ||
                                       event.touchType == TouchType.Cancel)
	                   {
                                  // Item is not touched anymore
		                  itemRoot.background = Color.Black
	                   }
                       }
              }
         }
   ]
}

 

Let me know if any doubt.