Essentials: Extra feature: Clipboard changed event

Created on 1 Feb 2019  ·  10Comments  ·  Source: xamarin/Essentials

I would like to have a clipboard changed event. So that when another app puts something on the clipboard, that my app can pick it up and do something with it.

For instance, if a device has a hardware scanner that scans barcodes and puts the result on the clipboard, our app should get the read barcode.

I have tried to use my old code for the change event ((AddPrimaryClipChangedListener)) together with Clipboard, but then the changed event is no longer triggered.

Kind regards,
Saskia

// Essentials Team Info
Researched a bit:

API:

public static event EventHandler<ClipboardChangedEventArgs> ClipboardChanged;

 public class ClipboardChangedEventArgs: EventArgs
    {

    }

We don't need to return any information in the eventargs, because our API should return this. It is a generic clipboard changed, we don't know if it is text or other items....

ready-to-implement up-for-grabs

Most helpful comment

Am working on it, a pr should be up before the end of the week 👍

All 10 comments

On IOS this feature might require setting up some code in the app initialization function. Should not be a problem on Android and iOS

Added documentation, should be pretty easy to do :) Up for grabs :)

The implementation can probably follow the pattern o the sensor events. When a handler is attached, then start the listeners, and when the last handler is detached, then stop the events.

Am working on it, a pr should be up before the end of the week 👍

@Mrnikbobjeff can you base it off of the 1.1.0 branch :)

@jamesmontemagno @Mrnikbobjeff looks like the code and docs were done here - https://github.com/xamarin/Essentials/pull/720

What's pending, if anything?
If so, can I pick it up and finish it off.

Implemented.

I tried to install version 1.4.0-pre2 to try the new event, but got this error message:
Failed to add reference. The package 'Xamarin.Essentials' tried to add a framework reference to 'System.Drawing.Common.dll' which was not found in the GAC.

Is this a problem with the package? Or do I need to install extra packages?

Thanks, Saskia

Hi,
I'm trying to use the package as well, with no luck.
If this is an open issue, can you please direct me and I will try to fix it.
With Warm Regards,Manish Kungwani

On Tuesday, 28 January, 2020, 03:50:40 pm IST, SaskiaL <[email protected]> wrote:

I tried to install version 1.4.0-pre2 to try the new event, but got this error message:
Failed to add reference. The package 'Xamarin.Essentials' tried to add a framework reference to 'System.Drawing.Common.dll' which was not found in the GAC.

Is this a problem with the package? Or do I need to install extra packages?

Thanks, Saskia


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

I have added the package 1.4.0 pre2 again and this time it worked.
I think I had to update some other packages. I'm sorry, I don't remember which package(s) exactly.
I started with a new app and tried it there and that worked. That gave me the idea to check the other nuget packages.

I tried the new onchange event and it works like a charm.

Thanks, Saskia

Was this page helpful?
0 / 5 - 0 ratings