feather::override
This command allows a Tcl script to change the behaviour of an existing command without polluting the namespace with renamed commands. It works by intercepting calls through the Command structure associated with each command. Commands can be overridden multiple times and can be restored in any order.
commandoriginal-commandIt can also be used as a command in which case it has the same behaviour as the overridden command had before it was overridden.
overriding-command
feather::override command command ?overriding-command?
feather::override set.
Returns an original-command.
feather::override get original-command
overriding-command associated with
original-command.
feather::override original command
feather::override restore original-command
feather::override set original-command overriding-command
% proc widget-proc {original method args} {
switch -- $method {
"configure" {
return [feather::invoke $original configure $args]
}
}
}
% proc widget {name args} {
# Create a frame.
feather::invoke frame [list $name] $args
# Override the widget command.
set original [feather::override command $name]
# Set the overriding command.
feather::override set $name [feather::curry ::widget-proc $original]
return $name
}