Closed AndyObtiva closed 2 years ago
OK, good news! It is not Ruby's fault! I recreated the same exact problem with Python and TKinter:
from tkinter import *
from tkinter import ttk
root = Tk()
text = Text(root)
text.grid()
text.insert('1.0', "Some giberish\nMore giberish\nNot well spelled giberish")
text.tag_add('all', '1.0', 'end')
def print_info(event):
print('key press')
print(event)
text.tag_bind('all', '<KeyPress>', print_info)
root.mainloop()
I reported at the ActiveState Community Forum (not sure where else to report): https://community.activestate.com/t/tk-text-tag-bind-issue-with-activetcl-8-6-occurs-when-using-tk-in-both-ruby-and-python/7665
I tried your example ruby program and can reproduce the issue using tk-8.5.19 on OpenBSD. So it doesn't appear to be specific to ActiveState's distribution, it's probably an issue in tk itself.
Since this doesn't appear to be a bug in ruby-tk, I'm going to close this now.
For those who may be interested to know, I would like to note that I reported this as an official Tcl/Tk issue: https://core.tcl-lang.org/tk/tktview/631a0b2d95b8426a8851829b16a9d77b9f79b03e
In light of the solution to https://github.com/ruby/tk/issues/36, I wrote code that monitored key presses upon moving around a
Tk::Text
widget with the arrow keys. It basically registers a listener to<KeyPress>
event on a pre-added tag that covers a range of index1.0
toend
.Here is a code example of this:
You can navigate around the
Tk::Text
widget using the arrow keys with no problem. It always fires the<KeyPress>
listener anywhere in the1.0
toend
range, printing the event information.Trouble starts once I clear all the text by highlighting with
CMD+A
and then hittingDELETE
. Afterwards, when I type new text and then move the arrow keys around, no firing of the<KeyPress>
event happens anymore.The plot thickens however. If I insert enough new lines, it sometimes starts firing again, albeit temporarily, and then it stops again.
Either way, the functionality seems broken. It is probably broken in ActiveTcl, not in the Ruby code, but I thought I'd report here just in case there is an issue in the Ruby code.
p.s. I am using ActiveTcl-8.6.9.8609.2-macosx10.9-x86_64-93b04018