Click on Drag Receiver

Drag Receivers are working fine by my experience, but a click on one triggers the procedure intended to process dropped files. Intercepting the click to either stop it or handle it differently doesn’t seem to be straight forward. Below is what I’ve come up with to stop anything from running but I’m wondering if there’s a better way.

If info(“dropfiles”) = “”
If Error

In Panorama X, pretty much every type of object is a button and will trigger code when clicked, including rectangles, stars, text display, whatever. This could be disabled, but I can think of situations where it might be useful to process clicks on a drag receiver (for example, you might set it up so that clicking on a drag receiver opens a file selection dialog), so I think I will leave it in. Though perhaps disabling clicks could be added as an option on an object-by-object basis.

For now, however, I think you can simply include this at the top of your code:

if info("droptypes")="" return endif

However, this would still allow dropped text. If you want to make sure only files have been dropped on your object, you could do this:

if catcherror("",info("dropfiles"))="" return endif

This is basically the same as your code, but I think a bit cleaner. I just love the catcherror(function in Panorama X, I use it all the time and very rarely use if error any more.

Here’s an example that would allow files to be dropped on the Drag Receiver, or the user can click on the Drag Receiver to select one or more files with a standard file selection dialog.

let chosenFiles = catcherror("",info("dropfiles"))
if chosenFiles = ""
    choosefiledialog chosenFiles,"Multiple",true()
    if chosenFiles = "" return endif
// continue to process chosenFiles

I’ll go for the catch error( as a good solution. Without an error trap, an error message appears so a simple Rtn is out.

As a matter of fact, in this case, I do want to run a procedure when the Drag Receiver is clicked. Clearly there are ways to deal with it but I was looking for something like an onClick( to immediately catch the fact that the object has been clicked upon. So in your spare time…

Here you go!

if info("droptypes")=""
    ... the user clicked the object
    ... the user dropped something on the object

Ammend that to info(“droptypes”) and it works.


Oops! For the benefit of anyone that comes across this later, I have corrected this in both of my posts above.