TIP #238: Fire Event when Widget Created
_____________________________________________________________________________
TIP:	238
Title:	Fire Event when Widget Created
Version:	$Revision: 1.7 $
Authors:	Gerald W. Lester <Gerald.Lester@cox.net>
State:	Draft
Type:	Project
Tcl-Version:	8.7
Vote:	Pending
Created:	Tue Jan 25 00:00:00 UTC 2005
Keywords:	Tk
Abstract
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.
Rationale
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.
Proposal
It is proposed that the virtual event <<Create>> be sent to every widget upon the creation of its actual underlying window (i.e. as part of Tk_MakeWindowExist). Note that this is the earliest at which an event can actually be delivered to the widget; before that, doing event generate to the widget just creates an event that gets discarded.
Example
% bind Toplevel <<Create>> 
    puts stdout New toplevel called %W was created!

% toplevel .foo
New toplevel called .foo was created!
Proposed C API Changes
No changes would be requried, this change is for the Tcl layer API.
Reference Implementation
A reference implementation does not yet exist.
Copyright
This document has been placed in the public domain.
_____________________________________________________________________________
Colophon
TIP AutoGenerator - written by Donal K. Fellows