Page 1 of 1
Drag pdf from the desktop to a field
Posted: Tue Nov 21, 2017 3:50 am
by mluka
Hi all.
OS X (10.12) and LC 8.
If I drag a pdf document from the desktop to a field, the only thing that gets copied is the document's name (the full path, actually).
Questions:
- Is it possible to have the contents of the pdf document "inserted" into the field?
- Is there an easy way, just by dragging from the desktop, to copy (icon + name) a pdf document and have that turn into an object (such as a button) that, when clicked, will "launch document..."
- What about "png" documents? "jpg" documents?
What I'm trying to do: create some kind of "notebook" that would allow, in addition to text typed in, the copying of external documents into the notebook. A la
Curio or
OmniOutliner...
Thanks.
Re: Drag pdf from the desktop to a field
Posted: Tue Nov 21, 2017 3:12 pm
by dunbarx
I do not think LC supports dragging text or pdf data into a field from the outside. Others may know better, though.
As for pulling something from the outside and having it appear as a native LC object, I believe you are limited to the actions of the "import as control" menuItem in the "edit" menu. Others may know better...
Craig Newman
Re: Drag pdf from the desktop to a field
Posted: Tue Nov 21, 2017 4:54 pm
by Klaus
Bonjour Michel,
of course LC supports Drag'n'Drop!
However PDF files can only be displayed in a Browser object out of the box on a Mac and on Windows if the Acrobat Reader web-plug-in has been installed.
To your questions:
1. See above, you cannot extract the text and/or images from a PDF file in Livecode and display it in a field object.
Example of Drag'n'Drop of file(s):
To "load" a dragged TXT document into a field, you need this in the script of that field:
Code: Select all
on dragenter
## Let this field accepty a Draga and Drop action
set the dragaction to "copy"
end dragenter
on dragdrop
## we only need the first dragged file
put line 1 of the dragdata["files"] into tFileName
## We only allow TXT files:
if tFileName ends with ".txt" then
## We have a TXT file and load it into this field
set the text of me to url("file:" & tFileName)
end if
end dragdrop
2. This is also possible but requires the use of custpom properties and behaviours, although this might be possible without a behaviour. Ready for this?
3. Yes, what about PNG and JPGs?
LC can display these in an image object, so what is your exact question here?
Hint:
To learn the basics of Livecode, I recommend going through these stacks:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
Re: Drag pdf from the desktop to a field
Posted: Tue Nov 21, 2017 5:27 pm
by dunbarx
Hmmm.
Everything Klaus said is true. Same for me
I think the OP was interested in the ability to drag objects, files and text directly from the desktop (from "outside" LC) either into LC directly as supported controls, or in the case of text, into LC fields.
But certainly within LC, drag and drop is fully supported.
Craig
Re: Drag pdf from the desktop to a field
Posted: Wed Nov 22, 2017 4:01 pm
by mluka
Hey guys! Thanks for the pointers.
I'll need a few days to look at them and figure out the limits of what's feasible. I'll come back with comments or, more likely, more questions.
I think the OP was interested in the ability to drag objects, files and text directly from the desktop (from "outside" LC) either into LC directly as supported controls, or in the case of text, into LC fields.
That's exactly it.
Thanks.
Re: Drag pdf from the desktop to a field
Posted: Wed Nov 22, 2017 4:14 pm
by Klaus
Bonjour Michel,
mluka wrote: ↑Wed Nov 22, 2017 4:01 pm
I think the OP was interested in the ability to drag objects, files and text directly from the desktop (from "outside" LC) either into LC directly as supported controls, or in the case of text, into LC fields.
That's exactly it.
ah, OK, this is possible, but requires SOME preparation in Livecode!
Best
Klaus
Re: Drag pdf from the desktop to a field
Posted: Wed Nov 22, 2017 5:50 pm
by jacque
The basics for any external file drag operation is to get the filename and then script whatever you need to do with that.
Klaus' example does that with a text file, but any file type will work if LC has support for the format. For PDF files, the script would create a web view and load the PDF into it.
Re: Drag pdf from the desktop to a field
Posted: Wed Nov 22, 2017 6:17 pm
by mluka
Hi Jacqueline. Thanks for the response.
create a web view
With "revBrowser"?
load the PDF into it
With "revBrowserOpen", for instance?
Thanks.
Re: Drag pdf from the desktop to a field
Posted: Wed Nov 22, 2017 6:28 pm
by Klaus
Why not use the browser widget? Much more user (LC developer) friendly than the old revopenbrowser etc. stuff!
You could e.g. prepare a hidden browser widget on your card and show it in case someone dropped a PDF onto your card.
Re: Drag pdf from the desktop to a field
Posted: Wed Nov 22, 2017 7:01 pm
by jacque
Either revBrowser or a widget would work. It's also possible to create widgets on the fly if you need to.
Re: Drag pdf from the desktop to a field
Posted: Thu Nov 23, 2017 5:32 pm
by MaxV
mluka wrote: ↑Tue Nov 21, 2017 3:50 am
Is it possible to have the
contents of the pdf document "inserted" into the field?
A PDF is a complex binary object just to print, you can select the text from a reader a drag into a livecode field.
Otherwise you could use
pdftotext program with the
shell function, so you extract just the text.
mluka wrote: ↑Tue Nov 21, 2017 3:50 am
Is there an easy way, just by dragging from the desktop, to copy (icon + name) a pdf document and have that turn into an object (such as a button) that, when clicked, will "launch document..."
What about "png" documents? "jpg" documents?
Yes, that's very easy in livecode, see
http://livecode.wikia.com/wiki/Drag_and_drop