Re: Pasting text and images together

2023-09-04 Thread Paul Dupuis via use-livecode

Do you have access to the Apple Developer web site?

A search didn't tell me much but I find the side terrible useless. 
Following a bunch of variable type definitions I wandered to this page: 
https://developer.apple.com/documentation/foundation/nsattributedstring/1530578-rtfd


Which also seemed useless to me. I was hoping to find some documentation 
that explicitly explained the format, rather than Apple API's to access 
the format.


The Wikipedia entry seemed more helpful 
(https://en.wikipedia.org/wiki/Rich_Text_Format_Directory) - it appears 
teh format is a "bundle" (or folder) of files, including an RTF file and 
how ever many media files.


While I don't fully follow this Stackoverflow discussion 
(https://stackoverflow.com/questions/18722314/how-to-get-rtf-contents-from-uipasteboard-after-uiwebview-copy) 
it appears the clipboard contents is UTF8 encoded, so perhaps doing a 
textDecode of UTF8 and then looking at the result may be helpful?




On 9/4/2023 3:36 PM, David Epstein via use-livecode wrote:

I do not know how my problems accessing the rawClipboardData were overcome, 
but I succeeded in reading the array values there.  So I was able to address my 
original question of how to reconstruct in LiveCode a combination of text and 
image copied from another program.  Conclusion thus far:  no success.  If 
anyone is interested in this and might have some further suggestions, read on.

When I use the control key to invoke from the contextual menu “copy image” on a 
web page, the fullClipboardData[“image”] gets a string of humanly 
unintelligible characters that, when used as the text of a LiveCode image 
object, shows the copied image.   I did this for the picture of Robert Cailliau 
on webpage https://livecode.com/core-benefits-of-livecode/.  Call this String A.

To see how this information might be stored when I have copied both text and image, 
I selected from the word before to the word after that same picture, chose “Copy,” 
and then inspected the rawClipboardData["com.apple.flat-rtfd”], which seemed 
the most promising candidate of the various clipboardData array values.  Call this 
String B.

Something that looks kind of like String A appears in String B, but it is not 
the same.

At char 4097 of String B I see the first few characters of the beginning of 
String A, and think this might define the PNG data to follow.  But what follows 
is not the same as String A.

Here’s the start of string A:

âPNG
IHDR,,y}éusRGBÆŒÈDeXIfMM*ái††,†,ÿ`ÇÁ@IDATxÏΩ

And here’s char 4097ff of String B;

âPNG
IHDR,,y}éu IDATxúÏΩ{¨mYv÷˜sƵˆ„ÏÛ∏˜ú{Îvuuwuπ‹.€Ìˆ«!,d«2$qä¯a«9éCj,d°!dÅ"EâàB

So my hope that String A could somehow be extracted from String B and used to 
“paste” the included image was disappointed.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together

2023-09-04 Thread David Epstein via use-livecode
I do not know how my problems accessing the rawClipboardData were overcome, 
but I succeeded in reading the array values there.  So I was able to address my 
original question of how to reconstruct in LiveCode a combination of text and 
image copied from another program.  Conclusion thus far:  no success.  If 
anyone is interested in this and might have some further suggestions, read on.

When I use the control key to invoke from the contextual menu “copy image” on a 
web page, the fullClipboardData[“image”] gets a string of humanly 
unintelligible characters that, when used as the text of a LiveCode image 
object, shows the copied image.   I did this for the picture of Robert Cailliau 
on webpage https://livecode.com/core-benefits-of-livecode/.  Call this String A.

To see how this information might be stored when I have copied both text and 
image, I selected from the word before to the word after that same picture, 
chose “Copy,” and then inspected the rawClipboardData["com.apple.flat-rtfd”], 
which seemed the most promising candidate of the various clipboardData array 
values.  Call this String B.

Something that looks kind of like String A appears in String B, but it is not 
the same.

At char 4097 of String B I see the first few characters of the beginning of 
String A, and think this might define the PNG data to follow.  But what follows 
is not the same as String A.

Here’s the start of string A:

âPNG
IHDR,,y}éusRGBÆŒÈDeXIfMM*ái††,†,ÿ`ÇÁ@IDATxÏΩ

And here’s char 4097ff of String B;

âPNG
IHDR,,y}éu IDATxúÏΩ{¨mYv÷˜sƵˆ„ÏÛ∏˜ú{Îvuuwuπ‹.€Ìˆ«!,d«2$qä¯a«9éCj,d°!dÅ"EâàB 

So my hope that String A could somehow be extracted from String B and used to 
“paste” the included image was disappointed. 

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together

2023-09-02 Thread Paul Dupuis via use-livecode
Your right. Something about the rawClipboardData fails with an error. 
Trying the fullClipboardData (code below) works. My guess is that there 
may be something about the first key (on my Windows system that is 
"text/html" where the slash is causing an error?  I'd need to look at it 
further - perhaps skip that key and try others. This may be a bug that 
may be worth reporting in the LC Quality center. You might get what you 
want from the fullClipboardData (below)



on mouseUp pMouseButton
  local n=1
  lock clipboard
  --
  put the keys of the fullClipboardData into myK3  ## THIS WORKS
  --
  repeat for each line k in myK3
    try
  put the fullClipboardData[k] into temp[n]  ## DOESN’T WORK
    catch myError
  put myError into e4[n] ## ERROR IS TRIGGERED
    end try
    add 1 to n
  end repeat
  unlock clipboard
end mouseUp


On 9/2/2023 5:07 PM, David Epstein via use-livecode wrote:

Paul, getting the keys of the rawClipboardData worked for me too.  What didn’t 
work was trying to read the values.  See this part of my script, I hope shown 
this time without the asterisks gMail added before:

lock clipboard
   …
put the keys of the rawClipboardData into myK3  ## THIS WORKS
…
repeat for each line k in myK3
   try
  put the rawClipboardData[k] into temp[n]  ## DOESN’T WORK
   catch myError
  put myError into e4[n] ## ERROR IS TRIGGERED
   end try
   add 1 to n
end repeat
unlock clipboard




From: Paul Dupuis 
To: use-livecode@lists.runrev.com
Subject: Re: Pasting text and images together?
Message-ID: <3814cd2a-0f20-2bbb-8783-42fc57e68...@researchware.com>
Content-Type: text/plain; charset=UTF-8; format=flowed

Since my method didn't work, I'd try Marks, namely to put the keys of
the clipboard array into a variable to look at

on mouseUp
? lock clipboard
? put the keys of the clipboarddata into tKeys1
? put the keys of the fullclipboarddata into tKeys2
? put the keys of the rawclipboarddata into tkeys3
? breakpoint
? unlock clipboard
end mouseUp

I tested this in LC 10dp6 and it works. Once you see what keys are
present with your mixed text and images copied to the clipboard, you can
choose which clipboard array and keys to work with to get the data.

-- Paul



On 9/2/2023 10:36 AM, David Epstein via use-livecode wrote:
Many thanks to Paul Dupuis and Mark Waddingham.  The script below tries to
test their suggestions.  Using 10.0.0 dp5 on an Intel Mac, and watching
execution after the breakpoint, I get errors at each "try" in the script.
So it does not seem that I can write the fullClipboardData
or rawClipboardData to an array variable; and it does not seem that I can
access any element of the rawClipboardData array.  Further advice is
welcome.

Best wishes,
David Epstein

*on* a2

*lock* clipboard

*put* the keys of the clipboardData into myK1

*put* the keys of the fullClipboardData into myK2

*put* the keys of the rawClipboardData into myK3

*breakpoint*

*try*

*put* the fullClipboardData into ta2

*catch* myError

*put* myError into e2

*end* *try*

*try*

*put* the rawClipboardData into ta3

*catch* myError

*put* myError into e3

*end* *try*

*put* 1 into n

*repeat* for each line k in myK3

*try*

*put* the rawClipboardData[k] into temp[n]

*catch* myError

*put* myError into e4[n]

*end* *try*

*add* 1 to n

*end* *repeat*

*unlock* clipboard

*end* a2

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together

2023-09-02 Thread David Epstein via use-livecode
Paul, getting the keys of the rawClipboardData worked for me too.  What didn’t 
work was trying to read the values.  See this part of my script, I hope shown 
this time without the asterisks gMail added before:

   lock clipboard
  …
   put the keys of the rawClipboardData into myK3  ## THIS WORKS
   …
   repeat for each line k in myK3
  try
 put the rawClipboardData[k] into temp[n]  ## DOESN’T WORK
  catch myError
 put myError into e4[n] ## ERROR IS TRIGGERED
  end try
  add 1 to n
   end repeat
   unlock clipboard



> From: Paul Dupuis 
> To: use-livecode@lists.runrev.com
> Subject: Re: Pasting text and images together?
> Message-ID: <3814cd2a-0f20-2bbb-8783-42fc57e68...@researchware.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
> 
> Since my method didn't work, I'd try Marks, namely to put the keys of 
> the clipboard array into a variable to look at
> 
> on mouseUp
> ? lock clipboard
> ? put the keys of the clipboarddata into tKeys1
> ? put the keys of the fullclipboarddata into tKeys2
> ? put the keys of the rawclipboarddata into tkeys3
> ? breakpoint
> ? unlock clipboard
> end mouseUp
> 
> I tested this in LC 10dp6 and it works. Once you see what keys are 
> present with your mixed text and images copied to the clipboard, you can 
> choose which clipboard array and keys to work with to get the data.
> 
> -- Paul
> 
> 
>> On 9/2/2023 10:36 AM, David Epstein via use-livecode wrote:
>> Many thanks to Paul Dupuis and Mark Waddingham.  The script below tries to
>> test their suggestions.  Using 10.0.0 dp5 on an Intel Mac, and watching
>> execution after the breakpoint, I get errors at each "try" in the script.
>> So it does not seem that I can write the fullClipboardData
>> or rawClipboardData to an array variable; and it does not seem that I can
>> access any element of the rawClipboardData array.  Further advice is
>> welcome.
>> 
>> Best wishes,
>> David Epstein
>> 
>> *on* a2
>> 
>> *lock* clipboard
>> 
>> *put* the keys of the clipboardData into myK1
>> 
>> *put* the keys of the fullClipboardData into myK2
>> 
>> *put* the keys of the rawClipboardData into myK3
>> 
>> *breakpoint*
>> 
>> *try*
>> 
>> *put* the fullClipboardData into ta2
>> 
>> *catch* myError
>> 
>> *put* myError into e2
>> 
>> *end* *try*
>> 
>> *try*
>> 
>> *put* the rawClipboardData into ta3
>> 
>> *catch* myError
>> 
>> *put* myError into e3
>> 
>> *end* *try*
>> 
>> *put* 1 into n
>> 
>> *repeat* for each line k in myK3
>> 
>> *try*
>> 
>> *put* the rawClipboardData[k] into temp[n]
>> 
>> *catch* myError
>> 
>> *put* myError into e4[n]
>> 
>> *end* *try*
>> 
>> *add* 1 to n
>> 
>> *end* *repeat*
>> 
>> *unlock* clipboard
>> 
>> *end* a2
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-09-02 Thread Paul Dupuis via use-livecode
Since my method didn't work, I'd try Marks, namely to put the keys of 
the clipboard array into a variable to look at


on mouseUp
  lock clipboard
  put the keys of the clipboarddata into tKeys1
  put the keys of the fullclipboarddata into tKeys2
  put the keys of the rawclipboarddata into tkeys3
  breakpoint
  unlock clipboard
end mouseUp

I tested this in LC 10dp6 and it works. Once you see what keys are 
present with your mixed text and images copied to the clipboard, you can 
choose which clipboard array and keys to work with to get the data.


-- Paul


On 9/2/2023 10:36 AM, David Epstein via use-livecode wrote:

Many thanks to Paul Dupuis and Mark Waddingham.  The script below tries to
test their suggestions.  Using 10.0.0 dp5 on an Intel Mac, and watching
execution after the breakpoint, I get errors at each "try" in the script.
So it does not seem that I can write the fullClipboardData
or rawClipboardData to an array variable; and it does not seem that I can
access any element of the rawClipboardData array.  Further advice is
welcome.

Best wishes,
David Epstein

*on* a2

*lock* clipboard

*put* the keys of the clipboardData into myK1

*put* the keys of the fullClipboardData into myK2

*put* the keys of the rawClipboardData into myK3

*breakpoint*

*try*

*put* the fullClipboardData into ta2

*catch* myError

*put* myError into e2

*end* *try*

*try*

*put* the rawClipboardData into ta3

*catch* myError

*put* myError into e3

*end* *try*

*put* 1 into n

*repeat* for each line k in myK3

*try*

*put* the rawClipboardData[k] into temp[n]

*catch* myError

*put* myError into e4[n]

*end* *try*

*add* 1 to n

*end* *repeat*

*unlock* clipboard

*end* a2
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-09-02 Thread David Epstein via use-livecode
Many thanks to Paul Dupuis and Mark Waddingham.  The script below tries to
test their suggestions.  Using 10.0.0 dp5 on an Intel Mac, and watching
execution after the breakpoint, I get errors at each "try" in the script.
So it does not seem that I can write the fullClipboardData
or rawClipboardData to an array variable; and it does not seem that I can
access any element of the rawClipboardData array.  Further advice is
welcome.

Best wishes,
David Epstein

*on* a2

*lock* clipboard

*put* the keys of the clipboardData into myK1

*put* the keys of the fullClipboardData into myK2

*put* the keys of the rawClipboardData into myK3

*breakpoint*

*try*

*put* the fullClipboardData into ta2

*catch* myError

*put* myError into e2

*end* *try*

*try*

*put* the rawClipboardData into ta3

*catch* myError

*put* myError into e3

*end* *try*

*put* 1 into n

*repeat* for each line k in myK3

*try*

*put* the rawClipboardData[k] into temp[n]

*catch* myError

*put* myError into e4[n]

*end* *try*

*add* 1 to n

*end* *repeat*

*unlock* clipboard

*end* a2
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-09-02 Thread Mark Waddingham via use-livecode
You could poke around the raw clipboard data - this is platform specific (in 
terms of the keys) but gives a complete reflection of the system clipboard:

lock clipboard
put the keys of the rawClipboardData
unlock clipboard

This will dump what raw data types are present - then you can fetch using ‘the 
rawClipboardData[key]’.

Note that you need to lock and unlock the clipboard around ‘raw’ access.

Warmest regards,

Mark.

Sent from my iPhone

> On 1 Sep 2023, at 20:33, David Epstein via use-livecode 
>  wrote:
> 
> To clarify my original question:
> 
> I'm not expecting the built-in paste command to handle this task; I'm
> wondering if I can script my own paste command to handle it.
> 
> Richmond, I can write a script to "paste" an image by itself (by creating
> an image and setting its text to clipboardData["image"]).
> 
> But is there some way I can access both the text and the image that are on
> the clipboard after I have copied a combination of those from, e.g., a web
> browser?  (Pasting to Apple Notes confirms that the clipboard contains both
> text and image.)
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-09-01 Thread J. Landman Gay via use-livecode

On 9/1/23 5:02 PM, Paul Dupuis via use-livecode wrote:
If the App copying the mixed content places it on the clipboard as text and an image vs some 
mixed type, you may be able to do this


Your have the on pasteKey message to trap CONTROL/COMMAND-V and if you have a "Paste" menu 
item, you control the script for that.


Note that LC traps the pastekey message, so you need to suspend the IDE to test 
it.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-09-01 Thread Paul Dupuis via use-livecode
If the App copying the mixed content places it on the clipboard as text 
and an image vs some mixed type, you may be able to do this


Your have the on pasteKey message to trap CONTROL/COMMAND-V and if you 
have a "Paste" menu item, you control the script for that.


the ClipboardData, the fullClipBoardData, and the rawClipboardData 
arrays (see Dictionary entries for each of these) give you access to the 
different elements on the clipboard. I epect the rawClipboardData will 
not really apply to this goal, but whether the ClipboardData or 
fullClipboardData would be better, I'm not sure


Essential for either the pasteKey or menu paste action, you scrip wants to

put the ClipboardData["text"] into tMyText -- the text copied to the 
clipboard
put the ClipboardData["image"] into tMyImageData -- the text property of 
an image object


As a test, you may need to write a small test handler

on pastekey
  local tClipArray, tFullClipArray
  put the ClipBoardData into tClipArray
  put the fullClipboardData into tFullClipArray
  breakpoint
end pasteKey

Copy mixed data to your clipboard from your 3rd party app, switch to a 
test stack with the script above (not tested), and press the paste keys 
for your OS. The IDE debugger should appear and let you look at the 
arrays tClipArray and tFullClipArray to see how the data was translated 
from your 3rd party app.



On 9/1/2023 3:32 PM, David Epstein via use-livecode wrote:

To clarify my original question:

I'm not expecting the built-in paste command to handle this task; I'm
wondering if I can script my own paste command to handle it.

Richmond, I can write a script to "paste" an image by itself (by creating
an image and setting its text to clipboardData["image"]).

But is there some way I can access both the text and the image that are on
the clipboard after I have copied a combination of those from, e.g., a web
browser?  (Pasting to Apple Notes confirms that the clipboard contains both
text and image.)
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-09-01 Thread David Epstein via use-livecode
To clarify my original question:

I'm not expecting the built-in paste command to handle this task; I'm
wondering if I can script my own paste command to handle it.

Richmond, I can write a script to "paste" an image by itself (by creating
an image and setting its text to clipboardData["image"]).

But is there some way I can access both the text and the image that are on
the clipboard after I have copied a combination of those from, e.g., a web
browser?  (Pasting to Apple Notes confirms that the clipboard contains both
text and image.)
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-08-30 Thread Richmond Mathewson via use-livecode

As far as I know image data cannot be pasted into LC.

I just tried pasting a banal image of a cat from an Ecosia search into a 
stack directly, and into an image, to no avail.


Best, Richmond.

On 30.08.23 19:35, David Epstein via use-livecode wrote:

 From a web browser, or from programs like Word or (Apple) Notes, it is 
possible to copy to the clipboard a single selection that includes both text 
and images.
Is there any way to paste all of this information to LiveCode—for example, 
placing the text in fields and the imageData in image objects, or showing 
everything in one field by setting the imageSource of some characters in that 
field?
After having copied such a collection of text and image information, the keys 
to the fullClipboardData seem only to include text and styled text options, 
with no indication of the images that are included on the clipboard.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Pasting text and images together?

2023-08-30 Thread David Epstein via use-livecode
From a web browser, or from programs like Word or (Apple) Notes, it is possible 
to copy to the clipboard a single selection that includes both text and images.
Is there any way to paste all of this information to LiveCode—for example, 
placing the text in fields and the imageData in image objects, or showing 
everything in one field by setting the imageSource of some characters in that 
field?
After having copied such a collection of text and image information, the keys 
to the fullClipboardData seem only to include text and styled text options, 
with no indication of the images that are included on the clipboard.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode