i need create draggable button. drag starts multiple source , ends @ sink. there way position of sources , sink after creation of page.
container { horizontalalignment: horizontalalignment.fill label { id: preid preferredwidth: 700 text: rootcontainer.data.part1 multiline: true textstyle { textalign: textalign.center color: color.black } horizontalalignment: horizontalalignment.center } } container { horizontalalignment: horizontalalignment.center sinkbutton { id: sinkid preferredheight: 100 preferredwidth: 686 textcolor: color.black enabled: false layoutproperties: absolutelayoutproperties { } } } container { horizontalalignment: horizontalalignment.fill toppadding: -5 bottompadding: squaredisplay ? 10 : 50 label { id: postid text: rootcontainer.data.postdata multiline: true textstyle { textalign: textalign.center color: color.black } horizontalalignment: horizontalalignment.center } } }
i want know position of "sinkid" relative window. position varies depending on "preid" text length. layoutupdatehandler
possible solution layoutframe.x
or layoutframe.y
comes 0 on checking. there way position of visual node on/after page creation?
first, layoutupdatehandler
reports layoutframe
properties quite well, not sure why it's not working in case. here working code demonstrating if want utilise class needs:
import bb.cascades 1.0 page { container { layout: docklayout {} horizontalalignment: horizontalalignment.fill verticalalignment: verticalalignment.fill button { id: button horizontalalignment: horizontalalignment.center verticalalignment: verticalalignment.center text: "click me" onclicked: { console.log("button layout - x:" + layouthandler.layoutframe.x + ", y:" + layouthandler.layoutframe.y + ", width:"+ layouthandler.layoutframe.width + ", height: " + layouthandler.layoutframe.height); } attachedobjects: [ layoutupdatehandler { id: layouthandler } ] } } }
also, if want respond touch events of widget guess draggable functionality means, best bet here use series of touch-input reactions provided touchbehaviors
added visualnode
via qml via c++, doesn't matter. in order this, need create touchbehavior
object defined touchreaction
respective properties.
so, example, tracking touch events of visualnode
upon receiving touch down event until touch 1 occurs need define respective touchbehaviour
object , connect ontouch()
slot of visualnode
events captured touchbehaviour
event filter. here code demonstrating approach:
import bb.cascades 1.0 page { container { layout: docklayout {} horizontalalignment: horizontalalignment.fill verticalalignment: verticalalignment.fill button { id: button horizontalalignment: horizontalalignment.center verticalalignment: verticalalignment.center text: "click me" touchbehaviors: [ touchbehavior { touchreaction { eventtype: touchtype.down phase: propagationphase.attarget response: touchresponse.starttracking } } ] ontouch: { console.log("===== got touch event of type " + event.touchtype + " ====="); console.log("\twindowx - " + event.windowx); console.log("\twindowx - " + event.windowx); console.log("\twindowy - " + event.windowy); console.log("\tlocalx - " + event.localx); console.log("\tlocaly - " + event.localy); console.log("\n"); } } } }
then can add logic in ontouch()
slot handler.
additional information on subject:
Comments
Post a Comment