How would I copy an image to the clipboard for android? IOS?


Mike Felker

David or anyone,

I have an image I want the user to CLICK (or double-click on). When the action is performed, I want it copied automatically to the clipboard. How would I do this? Is it the same for Android as it is for IOS?

Thank you.

Mike


Mike Felker

DecSoft

Hello,

Unfortunatelly I did not hear before about copy images into the clipboard. Apparently we can do it with text, at least using the below Cordova's plugin:

https://github.com/VersoSolutions/CordovaClipboard

... but I don't know about images... What you want to do? Maybe a another approach can be taken.



Mike Felker

OK - the app has a drop down with categories (sports). If you choose baseball, for example, then it will show all baseball emoji (custom emoji graphics). I then want the user to be able to click (or double click) one which will copy it to the clipboard so that they can then paste it into a text, document or whatever.

That is what I am trying to do.

Mike


Mike Felker

DecSoft

Hello Mike,

OK - the app has a drop down with categories (sports). If you choose baseball, for example, then it will show all baseball emoji (custom emoji graphics). I then want the user to be able to click (or double click) one which will copy it to the clipboard so that they can then paste it into a text, document or whatever.

That is what I am trying to do.

Mike

Then we are talking about copy the image's URL, not the image properly said. In that case we can use the refered plugin to deal with the Clipboard:

https://github.com/VersoSolutions/CordovaClipboard

This plugin is a good candidate to be added in App Builder "out of the box", however, I have no time right now to promise a day for that... but remember we can use the plugin even if they are not included in App Builder "out of the box": what we need to do is use the plugin Javascript API directly.

But now we enter in another point. Are the images we are talking about in a remote server? If so, we can use the "[ImageName.Image]" variable to be saved into the Clipboard, since that variable store the image URL.

Are the images we are talking about included by the application when compile it? Then I am not completely sure if the "[ImageName.Image]" can help us "as is". Of course such variable contains an URL, however, I am not sure what kind of URL is this (in Android, for example) and if they can be simply copied and used in another context.



DecSoft

Hello,

I am also study this stuff:

https://clipboardjs.com/



DecSoft

Hello again,

After taking a look (again, because I remember do it in the past) to clipboardjs.com and perform some tests I think this can be the option for us. I did not text in Android yet, but, since they are a Javascript solution, I think they can work without problems. If I found it working in Android (as well in browsers) I want to add a non visual Clipboard control to App Builder based in this stuff.

P.S. Remember you no need to wait... since it's possible to use the clipboardjs.com Javascript directly from our applications.



Mike Felker

Great! Any idea how I would code that in App Builder? I came up with this:

Does this look right? How would I code this in my app builder app? I am very new to programming javascript in your software, so not sure how to do it properly.

Thanks for your help.

Mike


Mike Felker

DecSoft

Hello,

Well. In fact the "clipboard.js" project offer us a way in order to about the usage of HTML markup. In fact we can add the "clipboard.min.js" file using the app's file's manager, and then use a Javascript like the below one:

Anyway, I am in the process to add a Clipboard control and the right sample for it. I expect to be ready this afternoon, so, you decide if you want to wait or you want to use the above Javascript: both things can be good Mike.



DecSoft

Hello,

Between other changes, this can be read in the current App Builder release history:

Add the new non visual Clipboard control. This control allow us to copy text into the system clipboard from our applications in conjuction with the also new CopyToClipboard action. Take also a look at the new Clipboard application sample to view it working.

Hope they can be useful for you and others Mike.



Mike Felker

I tried to download the update from within App Builder (check for updates), but received the error: "IOHandler value is not valid".

Now what?

Mike


Mike Felker

Mike Felker

OK. Downloaded it from your site. How would I use the sample app code to copy and paste the emoji images?

Mike


Mike Felker

DecSoft

Hello,

Please, Mike, take a look at my above post:


But now we enter in another point. Are the images we are talking about in a remote server? If so, we can use the "[ImageName.Image]" variable to be saved into the Clipboard, since that variable store the image URL.

Are the images we are talking about included by the application when compile it? Then I am not completely sure if the "[ImageName.Image]" can help us "as is". Of course such variable contains an URL, however, I am not sure what kind of URL is this (in Android, for example) and if they can be simply copied and used in another context.



Mike Felker

When I try copytoclipboard (thank you for making this command) on Image1.image I get "undefined" on the clipboard.

I am using an image control with the image located on my hard drive. Even if I use the file manager and embed the graphic (baseball.png) and show the relative path ("/app/images/baseball.png") it still shows up as "undefined".

What am I doing wrong?

Here is the off screen clipboard control code (as per your example):

Here is the copy to clipboard button code (as per your example):

Mike


Mike Felker

DecSoft

Hello,

Please take care about the match case. "[Image1.image]" is undefined because in fact we must to use "[Image1.Image]". Note the first upper cased "I" for the "Image".



Mike Felker

OK. That worked! However, when used on Android, when the user PASTE'S the clipboard contents to a text or email, will the image show up or just the path to the image? I need the image to be pasted. Is there any way to run this app on my Android phone to test - like a simulator?

Now I just need to figure out how to create multiple containers of some kind that can scroll and hold a number of small images (emoji) each and have them all be hidden until selected via the dropdown control (pick Baseball and the baseball emoji container displays, ready to be used with the copytoclipboard control.

How would I go about doing this? Thank for the hand holding while I get this done.

Mike


Mike Felker

DecSoft

Hello Mike,

Are you take a look at the Report control? App Builder includes various "Report*" samples, which can be give us an idea of this control power...



Mike Felker

I will look seriously at the report control.

I assume I use the Hidden option to hide/unhide

Something like that?

I assume I can do that to an entire Report holding a bunch of images?

Mike


Mike Felker

DecSoft

Hello,

Not exactly. To hide an element from a Report control we must "drop" it from the Report JSON source. That's the way. Maybe we can use an HTML control here instead of a Report control. But in both cases we are not talking about "Images.Image" anymore Mike.

If we decide to use a Report control then we have "items" and "item's properties" (what we want to put in a Report item, anything a JSON allow us) and if we use an HTML Control we are talking (probably) about HTML IMG elements "IDs" and "SRC" attributes.



Mike Felker

David,

It was great chatting with you. I had to take a phone meeting, so I apologize for leaving so abruptly.

As soon as you can, i'd still like to chat with you about paying for your services to finish my project.

Mike


Mike Felker

DecSoft

Hello Mike,

You're welcome. Hope you catch the app background issue. Please contact me by email or using the website contact form in order to talk about your project and a possible way to help you.


Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.