Previous Page  Developer's Guide: Tutorials
 How to use drag and drop and dynamic pictures
 5.3 Next Page

  • Make sure DesktopX is in authoring mode. Right click the DesktopX systray icon. If you see "Switch to Authoring mode", then select it.
  • Right click again the DesktopX systray icon and select "New Object".
  • A new object is created and the Properties panel for it is opened.
  • Click New in the Script section of the General tab.

Object Properties - New

  • The DesktopX Script Editor opens.

Script Editor 

  • Now copy and paste the following code into the editor:

Sub Object_OnDropFiles(files)
Object.picture = files
End Sub

  • Close the editor. Click Ok in the Properties panel.
  • Now try to drag and drop some image files over the object. The picture will change accordingly.
  • If you open the object properties again and look into States -> Appearance, Image path, you'll see that the current path changed to the last dragged image.
  • A couple things about the .Picture property: it works in 3 possible ways:
 Property   What it does
Object.Picture It will read/write the picture for the current state. It is suggested you use this only if your object has one state, use one of the other two methods if you have more states since that better guarantees the expected result.
Object.States("statename").Picture Picture It let you specify the actual state you want to modify.
Object.States("").Picture It'll read/apply the picture to ALL states.

Previous Page     Next Page