I’ve been searching but only coming up with posts that are several years old and so far, lots of suggestions that most people are saying don’t work or have issues.
I want to allow typing in the text area, but not cut and paste via any of the typical methods. In other words, no CTRL-V, No menu paste, no drag and drop, etc.
I just went into the Edit menu and made the paste option not visible and removed the Shortcut key, that did prevent pasting with the menu or control v. The problem is, that it’s for the entire app. I really only want to disable for a specific text box.
I will look at the drop object to prevent it there if possible.
it is also possible to add a “edit-paste” and “edit-copy” menu handler to a subclass of textarea
and return true to tell you deal with the copy and paste.
then try to override the “dropobject” event and return true also.
I’ve tried the subclass of the menu handler and didn’t seem to prevent it. Not having any luck with the drop object either. It actually blows my mind that there isn’t a simple way built in to do this.
I’m hoping someone has some actually code examples of how do accomplish this.
I did subclass the editpaste menu handler yesterday for a textaera subclass and I have been able to wipe the styled text infos to paste only the text without style. trust me it works.
it was on xojo 2019r11 though. pretty sure it still works in 2021r3.
Function EditPaste() As Boolean
If mPasteOnlyText Then
Dim c As New Clipboard
Dim ct As String = c.Text
c.Close
c = New Clipboard
c.Text = ct
c.Close
End If
Return False
End Function
That is true Arnaud. I only want the limitations on the one control, the textarea box. So far, I can’t seem to get anything to prevent cut and paste to it. If it doesn’t prevent ALL methods of pasting to the textarea it won’t meet my requirements.
On Windows, unless it has changed since I saw it, a read-only field loses its insert point; it’d become hard for the user to know where he’s going to write.
Thanks. I just tested on my Mac and windows and it works. Now I just need to review the code a bit and understand how to add the needed sections to my project.