For the first step, you need to create a Window and save it as "w_clickanddrag"
Unlike the static, if you want to add scripts inside the object, you need to create and utilize the user object.
So, create a new Picture user object, with Standard Visual type. Saved and named it as "uo_picture".
Set the image for the user object, and the other properties as you need. Then type this following scripts:
Clicked Event
1: this.Drag(Begin!)
DragDrop Event
1: this.visible = false
2: this.visible = true
3: this.setredraw(true)
4: w_clickanddrag.SetRedraw(true)
DragLeave Event
1: this.x = w_clickanddrag.pointerx( ) - (this.width / 2)
2: this.y = w_clickanddrag.pointery( ) - (this.height / 2)
3: this.setredraw(true)
4: w_clickanddrag.SetRedraw(true)
RButtonClicked Event
1: MessageBox("Hello","My name is "+This.tag)
All the above scripts are to simulate the click and drag event, and to show that every object has a different name (I'm using TAG properties to simulate the name).
Then, at w_clickanddrag window, you need to add a command button object and put this following code in Clicked Event, to create the new user object.
1: uo_picture uo_p2
2: uo_p2 = create uo_picture
3:
4: uo_p2.x = 100
5: uo_p2.y = 100
6: uo_p2.height = 250
7: uo_p2.width = 250
8: uo_p2.originalsize = true
9: uo_p2.tag = String(Time(Now())) // I'm using the time to generate the static name / tag
10:
11: parent.openuserobject( uo_p2, "p_2", 100, 100)
Try to run the window, and click the command button inside. Try to right click the picture object that has been created, to show the TAG properties.
No comments:
Post a Comment