It’s possible using something like UDHelmet or a custom control but would be a bit of a hack. I’d propose that we introduce a new cmdlet, like Set-UDClipboard and does all that magic for you.
Also when I look at the Network Developer Tab, I see the websocket message when I click the button to copy to clipboard, I also see the text value “hellocopy” but nothing copied to clipboard.
the set-udclipboard uses plain ol’ javascript to create an invisible element with the relative data.
As long as you’re not getting an error message during the creation of this element it should work unless your browser settings restrict clipboard access etc?
Which browser are you using? I admit, i only tested it on Chrome, however the javscript should function on all newer browser, from IE8+ i believe.
I’m using Chrome as well - Nothing is being blocked as I can go to other websites that have JS copy and it works as expected.
see the example site below - In the screen snip you can see the webpage, and when I click the Copy button the result is the copy text. Also, notice in the Console Debug there is an Action and Trigger… this never appears in the UD site Console.
Actually let me spend some time looking into my Dashboard… Just to make sure it was an issue with the cmdlet I added the button and Set-UDClipboard to the default poshud site in the nightly build module folder and it works.
So I have no idea why it does not work in my dashboard… I will have to pull it apart. Will post back when I find something.
Hmmm I think I found the issue - When the Button that is triggering the Copy clipboard cmdlet is in a Modal the copy does not work. When I move the button with the copy outside of a modal to display on the page the copy works.
This issue seems to have reappeared in 2.10.2 of PowerShell Universal (or somewhere between 2.7.2 and 2.10.2).
We were using New-UDClipboard in a modal, which has stopped working after an update to 2.10.2 and is now returning the error “Cannot bind argument to parameter ‘Data’ because it is an empty string” in a toast.