c++ - How to handle touch events of custom control in blackberry10 -
i have custom control called customcontextmenu.qml
, has image , label in each row. want handle click/touch on image , label together. how should that?
currently, add ontouch()
in each container containing image , label, it's not working. using customcontextmenu
control in main.qml
.
container { id: testpagecustommboxcontainer objectname: "testpagecustommboxcontainer" background:dropdownback.imagepaint attachedobjects: [ imagepaintdefinition { id: dropdownback repeatpattern: repeatpattern.fill imagesource: "asset:///images/dropdown_bg.png" } ] layout: stacklayout { orientation: layoutorientation.toptobottom } maxwidth: 200.0 maxheight: 180.0 horizontalalignment: horizontalalignment.right verticalalignment: verticalalignment.top container { id: testpagecustommboxretestcontainer objectname: "testpagecustommboxretestcontainer" preferredwidth:200.0 preferredheight:90.0 layout: stacklayout { orientation: layoutorientation.lefttoright } leftpadding: 10.0 toppadding: 10.0 bottompadding: 10.0 rightpadding: 20.0 imageview { imagesource: "asset:///images/retest.png" scalingmethod: scalingmethod.aspectfit verticalalignment: verticalalignment.center layoutproperties: stacklayoutproperties { spacequota: 1.0 } } label { text: "retest" horizontalalignment: horizontalalignment.right verticalalignment: verticalalignment.center textformat: textformat.plain layoutproperties: stacklayoutproperties { spacequota: 3.0 } } ontouch: { var retestpage = retestpage.createobject(); testnavigationpane.push(retestpage); } attachedobjects: [ componentdefinition { id:retestpage source: "main.qml" } ] } container { id: testpagecustommboxhelpcontainer objectname: "testpagecustommboxhelpcontainer" preferredwidth: 200.0 preferredheight: 90.0 layout: stacklayout { orientation: layoutorientation.lefttoright } leftpadding: 10.0 toppadding: 5.0 bottompadding: 15.0 rightpadding: 20.0 imageview { imagesource: "asset:///images/help.png" scalingmethod: scalingmethod.aspectfit verticalalignment: verticalalignment.center layoutproperties: stacklayoutproperties { spacequota: 1.0 } } label { text: "help" horizontalalignment: horizontalalignment.right verticalalignment: verticalalignment.center textformat: textformat.plain layoutproperties: stacklayoutproperties { spacequota: 3.0 } ontouch: { var helppage = helppage.createobject(); testnavigationpane.push(helppage); } attachedobjects: [ componentdefinition { id: helppage source: "helppage.qml" page { paneproperties: navigationpaneproperties { backbutton: actionitem { ontriggered: { testnavigationpane.pop(); } } } } } ] } }
you need use gesture handlers things such touched or longpressed. ontouch event used if trying while user holds finger down or similar. here example of code show differences between two:
//touched event - fires if user touches , lets go of element. //this preferred method gesturehandlers: [ taphandler { ontapped: { //code goes here } } ] //display active image if touched //this used such changing background color of button when pressed. ontouch: { if (event.touchtype == touchtype.down) { //do on down touch - e.g. change background color } else if (event.touchtype == touchtype.up || event.touchtype == touchtype.cancel) { //users finger has been lifted or has left element. } }
Comments
Post a Comment