# Most elegant way to 'reroute' Text widget events?

**URL:** <https://www.ruby-forum.com/t/most-elegant-way-to-reroute-text-widget-events/147463>\
**Category:** Ruby\
**Created:** [September 2, 2008, 4:43am UTC](https://www.ruby-forum.com/t/most-elegant-way-to-reroute-text-widget-events/147463 "2008-09-02T04:43:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenneth\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dc4da7/32.png) [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Post date:** [September 2, 2008, 4:43am UTC](https://www.ruby-forum.com/t/most-elegant-way-to-reroute-text-widget-events/147463/1 "2008-09-02T04:43:45Z")

</div>

After a couple of unsuccessful experiments, I’m afraid it’s time to  
ask the group. What I want to do is to use the text widget for  
display, but to have keyboard events processed solely by Ruby. I’ve so  
far been unsuccessful in unbinding any of the text widget’s built-in  
functionality, and don’t want to go in and modify text.tcl, as that  
strikes me as highly inelegant. I’m assuming that somehow I need to  
(1) unbind the text widget I’m using from all events, and then (2)  
bind all key events to (say) the top-level window. Unfortunately, my  
attempts at this have met with little success. (None). Could some Tk-  
fu master point me in the right direction? (At the moment, I simply  
can’t get things unbound from the text widget; I thought  
text.bindtags([]) might work, but it didn’t.)

Many thanks,  
Ken

---

<div class="post-metadata">

**Author:** ![Kenneth\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dc4da7/32.png) [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Post date:** [September 2, 2008, 5:35am UTC](https://www.ruby-forum.com/t/most-elegant-way-to-reroute-text-widget-events/147463/2 "2008-09-02T05:35:46Z")

</div>

From: Kenneth McDonald [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Most elegant way to ‘reroute’ Text widget events?  
Date: Tue, 2 Sep 2008 11:37:33 +0900  
Message-ID: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> strikes me as highly inelegant. I’m assuming that somehow I need to  
> (1) unbind the text widget I’m using from all events, and then (2)  
> bind all key events to (say) the top-level window. Unfortunately, my  
> attempts at this have met with little success. (None). Could some Tk-  
> fu master point me in the right direction? (At the moment, I simply  
> can’t get things unbound from the text widget; I thought  
> text.bindtags([]) might work, but it didn’t.)

Probably, the most simple way is

---

<div class="post-metadata">

**Author:** ![Kenneth\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dc4da7/32.png) [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Post date:** [September 2, 2008, 5:56am UTC](https://www.ruby-forum.com/t/most-elegant-way-to-reroute-text-widget-events/147463/3 "2008-09-02T05:56:48Z")

</div>

Hidetoshi,

Thanks for all your help, it’s been great. I would never have figured  
out that  
one–I’m trying to translate too literally from Tcl.

Ken
