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
simon_hain
Posts: 15,874
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany
Accepted Solution

Using a Button in a ListView

I have a Button in one of my ListItemComponents.

This button "consumes" the click event and emits clicked, but:

from the ListItemComponent i cannot access the outer qml page (or the classes registered from c++).

When i click on another part of the component the onTriggered of the ListView is called, but not when i click the button.

 

Is there a way to

- disable the "consume click" behavior of the button or

- access the qml or c++ class from the ListItemComponent

?

----------------------------------------------------------
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
Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Using a Button in a ListView

See my post here, should give you an idea of how to reach out of the listitemcomponent

http://supportforums.blackberry.com/t5/Cascades-Development/Images-in-s-listview/m-p/1965135#M5416
Like all of my posts
Please use plain text.
Developer
simon_hain
Posts: 15,874
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Using a Button in a ListView

Hmm, no, i don't get it from this post, could you describe it or give me a quick sample?
----------------------------------------------------------
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
Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Using a Button in a ListView

[ Edited ]

Now I could have totally misunderstood the question but this is what I thought you were asking... The same would go for if you used a custom qml component as the contents of the listitemcomponent. You would do the accessing of the listview in the same way from inside that class, or from a gesturehandler defined inline in the listitemcomponent definition.

 

Container {
	id: page1 //or whatever component with a context property set for your c++ class
	ListView {
		id: mylistview
		ListItemComponents: [
			ListItemComponent {
				id: mycomp
				Container {
					id: containerContents
					Label { text: "my list item" + ListItemData.title; }
					gestureHandlers: [
						TapHandler {
							onTapped: containerContents.ListItem.view.doSomethingWithItem(ListItemData);
						}						
					]				
				}			
			}
		]
		function doSomethingWithItem(data) {
			contextProp.callCPPMethod(data); //or do something else with it		
		}		
	}
}

 

Like all of my posts
Please use plain text.