beetlebug▾
/

canvas bind

Binds a script to an event on the items of a tag or an ID.

PATHNAME bind TAGORID ?SEQUENCE? ?SCRIPT?

Description

With SEQUENCE and SCRIPT, runs SCRIPT when the event of SEQUENCE happens on an item of TAGORID, as bind does for a widget. A SCRIPT that starts with + adds to the old script, and an empty SCRIPT removes the binding. With SEQUENCE only, gives its script. With no SEQUENCE, gives the sequences that TAGORID has.

The events of the pointer go to the item under the pointer, with the tag current. The events of the keys go to the item of focus.

Returns

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

Examples

% canvas .bi
> .bi create rectangle 0 0 10 10 -tags box
> .bi bind box <Button-1> {set ::clicked 1}
> .bi bind box
<Button-1>

Errors

% canvas .bi2; .bi2 bind
wrong # args: should be ".bi2 bind tagOrId ?sequence? ?command?"
-errorcode NONE

Facts

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

See also