beetlebug▾
/

wm protocol

Gives or sets the script for a request of the window manager, such as a click on the close button.

wm protocol WINDOW ?NAME? ?SCRIPT?

Description

ztk has one protocol, WM_DELETE_WINDOW: the request to close the window. With a script for it, a close request runs the script. With no script, a close request destroys the window. With NAME and SCRIPT, sets the script, and an empty SCRIPT removes it. With NAME, gives its script. With no NAME, gives the names of the protocols that have a script.

Returns

A script, a list of names, or an empty string.

Examples

% toplevel .t
> wm protocol .t WM_DELETE_WINDOW {set ::closing 1}
> list [wm protocol .t] [wm protocol .t WM_DELETE_WINDOW]
WM_DELETE_WINDOW {set ::closing 1}

% wm protocol .t WM_DELETE_WINDOW {}
> wm protocol .t

Errors

% wm protocol .t a b c
wrong # args: should be "wm protocol window ?name? ?command?"
-errorcode NONE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1