BindTable.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:7k
- '"
- '" Copyright (c) 1994 The Regents of the University of California.
- '" Copyright (c) 1994-1996 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: BindTable.3,v 1.3 2002/08/05 04:30:38 dgp Exp $
- '"
- .so man.macros
- .TH Tk_CreateBindingTable 3 4.0 Tk "Tk Library Procedures"
- .BS
- .SH NAME
- Tk_CreateBindingTable, Tk_DeleteBindingTable, Tk_CreateBinding, Tk_DeleteBinding, Tk_GetBinding, Tk_GetAllBindings, Tk_DeleteAllBindings, Tk_BindEvent - invoke scripts in response to X events
- .SH SYNOPSIS
- .nf
- fB#include <tk.h>fR
- .sp
- Tk_BindingTable
- fBTk_CreateBindingTable(fIinterpfB)fR
- .sp
- fBTk_DeleteBindingTable(fIbindingTablefB)fR
- .sp
- unsigned long
- fBTk_CreateBinding(fIinterp, bindingTable, object, eventString, script, appendfB)fR
- .sp
- int
- fBTk_DeleteBinding(fIinterp, bindingTable, object, eventStringfB)fR
- .sp
- CONST char *
- fBTk_GetBinding(fIinterp, bindingTable, object, eventStringfB)fR
- .sp
- fBTk_GetAllBindings(fIinterp, bindingTable, objectfB)fR
- .sp
- fBTk_DeleteAllBindings(fIbindingTable, objectfB)fR
- .sp
- fBTk_BindEvent(fIbindingTable, eventPtr, tkwin, numObjects, objectPtrfB)fR
- .SH ARGUMENTS
- .AS Tk_BindingTable bindingTable
- .AP Tcl_Interp *interp in
- Interpreter to use when invoking bindings in binding table. Also
- used for returning results and errors from binding procedures.
- .AP Tk_BindingTable bindingTable in
- Token for binding table; must have been returned by some previous
- call to fBTk_CreateBindingTablefR.
- .AP ClientData object in
- Identifies object with which binding is associated.
- .AP "CONST char" *eventString in
- String describing event sequence.
- .AP char *script in
- Tcl script to invoke when binding triggers.
- .AP int append in
- Non-zero means append fIscriptfR to existing script for binding,
- if any; zero means replace existing script with new one.
- .AP XEvent *eventPtr in
- X event to match against bindings in fIbindingTablefR.
- .AP Tk_Window tkwin in
- Identifier for any window on the display where the event occurred.
- Used to find display-related information such as key maps.
- .AP int numObjects in
- Number of object identifiers pointed to by fIobjectPtrfR.
- .AP ClientData *objectPtr in
- Points to an array of object identifiers: bindings will be considered
- for each of these objects in order from first to last.
- .BE
- .SH DESCRIPTION
- .PP
- These procedures provide a general-purpose mechanism for creating
- and invoking bindings.
- Bindings are organized in terms of fIbinding tablesfR.
- A binding table consists of a collection of bindings plus a history
- of recent events.
- Within a binding table, bindings are associated with fIobjectsfR.
- The meaning of an object is defined by clients of the binding package.
- For example, Tk keeps uses one binding table to hold all of the bindings
- created by the fBbindfR command.
- For this table, objects are pointers to strings such as window names, class
- names, or other binding tags such as fBallfR.
- Tk also keeps a separate binding table for each canvas widget, which manages
- bindings created by the canvas's fBbindfR widget command; within
- this table, an object is either a pointer to the internal structure for a
- canvas item or a Tk_Uid identifying a tag.
- .PP
- The procedure fBTk_CreateBindingTablefR creates a new binding
- table and associates fIinterpfR with it (when bindings in the
- table are invoked, the scripts will be evaluated in fIinterpfR).
- fBTk_CreateBindingTablefR returns a token for the table, which
- must be used in calls to other procedures such as fBTk_CreateBindingfR
- or fBTk_BindEventfR.
- .PP
- fBTk_DeleteBindingTablefR frees all of the state associated
- with a binding table.
- Once it returns the caller should not use the fIbindingTablefR
- token again.
- .PP
- fBTk_CreateBindingfR adds a new binding to an existing table.
- The fIobjectfR argument identifies the object with which the
- binding is to be associated, and it may be any one-word value.
- Typically it is a pointer to a string or data structure.
- The fIeventStringfR argument identifies the event or sequence
- of events for the binding; see the documentation for the
- fBbindfR command for a description of its format.
- fIscriptfR is the Tcl script to be evaluated when the binding
- triggers.
- fIappendfR indicates what to do if there already
- exists a binding for fIobjectfR and fIeventStringfR: if fIappendfR
- is zero then fIscriptfR replaces the old script; if fIappendfR
- is non-zero then the new script is appended to the old one.
- fBTk_CreateBindingfR returns an X event mask for all the events
- associated with the bindings.
- This information may be useful to invoke fBXSelectInputfR to
- select relevant events, or to disallow the use of certain events
- in bindings.
- If an error occurred while creating the binding (e.g., fIeventStringfR
- refers to a non-existent event), then 0 is returned and an error
- message is left in fIinterp->resultfR.
- .PP
- fBTk_DeleteBindingfR removes from fIbindingTablefR the
- binding given by fIobjectfR and fIeventStringfR, if
- such a binding exists.
- fBTk_DeleteBindingfR always returns TCL_OK.
- In some cases it may reset fIinterp->resultfR to the default
- empty value.
- .PP
- fBTk_GetBindingfR returns a pointer to the script associated
- with fIeventStringfR and fIobjectfR in fIbindingTablefR.
- If no such binding exists then NULL is returned and an error
- message is left in fIinterp->resultfR.
- .PP
- fBTk_GetAllBindingsfR returns in fIinterp->resultfR a list
- of all the event strings for which there are bindings in
- fIbindingTablefR associated with fIobjectfR.
- If there are no bindings for fIobjectfR then an empty
- string is returned in fIinterp->resultfR.
- .PP
- fBTk_DeleteAllBindingsfR deletes all of the bindings in
- fIbindingTablefR that are associated with fIobjectfR.
- .PP
- fBTk_BindEventfR is called to process an event.
- It makes a copy of the event in an internal history list associated
- with the binding table, then it checks for bindings that match
- the event.
- fBTk_BindEventfR processes each of the objects pointed to
- by fIobjectPtrfR in turn.
- For each object, it finds all the bindings that match the current
- event history, selects the most specific binding using the priority
- mechanism described in the documentation for fBbindfR,
- and invokes the script for that binding.
- If there are no matching bindings for a particular object, then
- the object is skipped.
- fBTk_BindEventfR continues through all of the objects, handling
- exceptions such as errors, fBbreakfR, and fBcontinuefR as
- described in the documentation for fBbindfR.
- .SH KEYWORDS
- binding, event, object, script