Page 1 of 1

How to Re-select LiveCode as the "live" app on a dragdrop?

Posted: Tue Apr 23, 2013 11:00 pm
by MouseUp
Hi LC Gurus,

I am implementing a simple drag and drop of a data file from the Mac Finder into a text field. I have a dialogue come up if the destination field already has something in it asking if I want to replace the data. The problem I am having is that when the dialogue comes up, the Mac Finder is active and LiveCode is not the active application since I dragged the file from the Finder. And this means I have to click the mouse twice to select an answer button.

So the question is: What is the script line to "select LiveCode" and make LiveCode the active app so that I don't have to click twice on the dialogue box (once to select LiveCode and once to click the button)?

Code: Select all

on dragEnter -- show a green outline around the drop target
   set the borderColor of me to "green"
   pass dragEnter
end dragEnter

on dragdrop
   if the dragData["files"] is not empty and me is not empty then
      beep
      answer question "Replace with new data?" with "Cancel" or "OK" as sheet
      -- select this stack -- here's the problem. How do I make LiveCode the app and not the Mac Finder?
      if it is "Cancel" then exit dragdrop
   end if
   put URL ("file:" & line 1 of the dragData["files"]) into me
   set the borderColor of me to empty
end dragdrop

on dragLeave
   set the borderColor of me to empty
   pass dragLeave
end dragLeave

Re: How to Re-select LiveCode as the "live" app on a dragdro

Posted: Tue Apr 23, 2013 11:32 pm
by Simon
Try resumeStack in the dropbox.

Simon
Edit: Sorry too fast
on resumeStack
focus on me

Re: How to Re-select LiveCode as the "live" app on a dragdro

Posted: Wed Apr 24, 2013 6:55 pm
by jacque
Another option is just to not use a dialog box, which most operating systems are discouraging now anyway because they're intrusive. If the field already has content, don't allow a drop. Set the dragACtion to "none" on dragEnter.

Re: How to Re-select LiveCode as the "live" app on a dragdro

Posted: Wed Apr 24, 2013 11:44 pm
by MouseUp
Still no luck in getting LiveCode to be the active app via the script. Any more ideas?

Re: How to Re-select LiveCode as the "live" app on a dragdro

Posted: Sun Aug 04, 2013 8:17 pm
by [-hh]
..........