dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

Full Clipboard Access #19547

Open erezklr opened 11 months ago

erezklr commented 11 months ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

No response

Describe the solution you'd like

Receive from the clipboard not only text but also images, RTF and HTML and all the other objects it allows

Additional context

No response

martincostello commented 11 months ago

Could you explain what you're trying to achieve and in what context?

ghost commented 11 months ago

Hi @erezklr. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

erezklr commented 11 months ago

A few years ago I wrote a helper systemin WPF to help with academic research. Among the rest of the features was the ability to directly copy information that the researcher transferred to the clipboard, This information could be text, images, or RTF. I want to convert it to MAUI but I can't because I lack this ability, you can only take text from the clipboard. Attach sample code from WPF: if (!IsClipboardEmpty()) { IDataObject data_object = Clipboard.GetDataObject();

if (data_object.GetDataPresent(DataFormats.Bitmap))
{

}
else if (data_object.GetDataPresent(DataFormats.Rtf))
{

        var rtfText = Clipboard.GetText(TextDataFormat.Rtf).ToString();

    }

}
else if (data_object.GetDataPresent(DataFormats.Html))
{
    try
    {
        data = data_object.GetData(DataFormats.Html).ToString();

}
else if (data_object.GetDataPresent(DataFormats.Text))
{
    string str = data_object.GetData(DataFormats.Text).ToString();

} 
martincostello commented 11 months ago

Looks like an issue to be transferred to dotnet/maui.

drasticactions commented 11 months ago

https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/data/clipboard?view=net-maui-8.0#using-clipboard

The essentials API for Clipboard is limited to strings, and is called out in the docs. The platforms MAUI targets don't all have the same feature set as what WPF offers, so I doubt there could be a consistent way to offer the same functionality through a cross-platform API. As it stands, for this API, it's not a bug.

@mattleibow what do you think?