To Prevent Copying Text Displayed in TkText

Asked 2 years ago, Updated 2 years ago, 85 views

I use ruby's TkText to display the text and use bind to right-click and move the mouse.

Is it possible to prohibit copying text using the mouse?
You can set state to disabled to prevent text editing, but you can copy text.

Please tell me how to prohibit copying text displayed on TkText.

ruby

2022-09-30 21:16

1 Answers

Why don't you set TkText exportselection to false?

require'tk'

text=TkText.new('exportselection'=>false)
text.pack('fill'=>'both')
quitButton=TkButton.new(nil, 'text'=>'quit', 'command'=>proc {exit})
quitbutton.pack('fill'=>'both')

Tk.mainloop

However, exportselection has been described as targeting X Window System selection, so it may not work as expected in environments with a window system other than X Window System.


2022-09-30 21:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.