Does anybody have a working solution for disabling...
# compose-desktop
s
Does anybody have a working solution for disabling to copy and cut text from a password text field? I found some questions on SO with hacky workarounds, but I think might be working on Android only and not on desktop https://stackoverflow.com/questions/70518908/how-to-disable-copy-paste-cut-in-a-textfield-jetpack-compose
also found this thread: https://app.slack.com/client/T09229ZC6/CJLTWPH7S/thread/CJLTWPH7S-1664452514.539959 but I think it's also focused on Android
e
Not an answer but preventing paste would prevent users from using a password manager
s
yeah, pasting should still be enabled, just copying and cutting out of the text field should get disabled
Our current work in progress solution is this:
Copy code
LocalClipboardManager provides object : ClipboardManager {
    override fun getText() = clipboardManager.getText() // allow pasting text from clipboard
    override fun setText(annotatedString: AnnotatedString) = Unit // don't allow copying text into clipboard
}
it does more or less what we like to do, i.e. copying from the textfield is effectively impossible, however the UI still shows the Cut/Copy buttons when text is selected and right-clicked.
o
I think this deserves an issue to be filed
s
475 Views