This is not necessarily the current version of this TIP.
| TIP: | 238 |
| Title: | Fire Event when Widget Created |
| Version: | $Revision: 1.3 $ |
| Author: | Gerald W. Lester <Gerald dot Lester at cox dot net> |
| State: | Draft |
| Type: | Project |
| Tcl-Version: | 8.6 |
| Vote: | Pending |
| Created: | Tuesday, 25 January 2005 |
| Keywords: | Tk |
This TIP arranged for a new virtual event to be fired every time a widget is created. This allows class bindings to automatically discover new widget instances and act on their creation.
It would be useful if it was possible to set an event on class bindings to allow custom code to be run when a widget of a particular class is created.
Note that the standard X11 <Create> event is not quite suitable, because that is delivered to the X11 parent of the widget, which is not Tk in the case of toplevel windows. It is also delivered when the underlying window is created and not earlier, when its representative Tk widget is created.
It is proposed that the virtual event <<Create>> be sent to every widget upon its creation. (This means that only bindings on classes, toplevels and "all" will actually be able to trap it.)
% bind Toplevel <<Create>> {
puts stdout {New toplevel called {%W} was created!}
}
% toplevel .foo
New toplevel called {.foo} was created!
No changes would be requried, this change is for the Tcl layer API.
A reference implementation does not yet exist.
This document has been placed in the public domain.
This is not necessarily the current version of this TIP.