This article will show you how to make an object to be click and drag capable in Powerbuilder. In this case, I'm using Powerbuilder 9.0 and Picture Object. In this version, I found DragAuto property in the list of the picture property, one that I can't found in version 6.5. I'm not sure, since when Sybase added this property.
The Drag Auto property determines whether PowerBuilder puts the control into drag mode automatically. If the property is enabled, when the user clicks the control and starts dragging it, PowerBuilder puts the control in drag mode. Clicking the control triggers a DragDrop event, not a Clicked event.
If Drag Auto is not enabled, then when the user clicks the control, PowerBuilder does not put the control in drag mode. You have to call the Drag function to put the control into drag mode.
In the Window, put 1 Picture object, and set the name of the file, and turn on the DragAuto option, in other tabs of property, and named it as p_1
Add the following script in p_1's clicked event
this.Drag(begin!)
At the p_1's dragleave event, put this following script:
this.x = parent.pointerx( ) - (this.width / 2)this.y = parent.pointery( ) - (this.height / 2)parent.setredraw(true)this.setredraw(true)
And finally, at p_1's dragdrop event, add this following script:
parent.setredraw(true)this.setredraw(true)
this.Drag(end!)
»» READMORE...