Hi,
I have the code below in a segmented control’s action event.
It obviously produces a THIS ITEM DOES NOT EXIST error, because the obj refers to canvas1.
My question is - how do I path to a dropped object in Canvas1 from the segmented control??
// CHECK IF AN IMAGE WAS DROPPED ONTO CANVAS1
if obj.FolderItemAvailable and not obj.FolderItem.Directory then
MsgBox("Hello World")
End if
Yes, that’s why I added a property in a module, to hold the obj.folderItem, and then be able to call it from elsewhere.
But I have obviously gone wrong somewhere?
[quote=108688:@Richard Summers]Yes, that’s why I added a property in a module, to hold the obj.folderItem, and then be able to call it from elsewhere.
But I have obviously gone wrong somewhere?[/quote]
Maybe you need to call your module variable name instead of “obj”.
So basically I cannot check to see if an item has been dropped, or if it is a directory because those properties are not available in the segmented control, only for the canvas.
So my question now is - how do I get access to those properties, if I am in a segmented control?
Once you have saved the folderitem, check it for nil. You will eventually want to reset it, but if you want to access the last item dropped on the canvas, use
if droppedFolderItem <> nil then
// do something with droppedFolderItem
end
It is not necessary to check obj.FolderItemAvailable from the segmented control. The presence or absence of droppedFolderItem implies that information. In other words, if droppedFolderItem is nil, then nothing has been dropped on the canvas. If it is not nil, then obviously, something has been dropped. The only issue is, how long do you want droppedFolderItem to live? How long before that information becomes “stale”.