## Tcl8.6.17/Tk8.6.17 Documentation > Tk C API > BindTable

### Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

  NAME
    Tk_CreateBindingTable, Tk_DeleteBindingTable, Tk_CreateBinding, Tk_DeleteBinding, Tk_GetBinding, Tk_GetAllBindings, Tk_DeleteAllBindings, Tk_BindEvent — X 行事に対応して記述譜を起動する invoke scripts in response to X events
  SYNOPSIS
    #include <tk.h>
    Tk_BindingTable
    Tk_CreateBindingTable(interp)
    Tk_DeleteBindingTable(bindingTable)
    unsigned long
    Tk_CreateBinding(interp, bindingTable, object, eventString, script, append)
    int
    Tk_DeleteBinding(interp, bindingTable, object, eventString)
    const char *
    Tk_GetBinding(interp, bindingTable, object, eventString)
    Tk_GetAllBindings(interp, bindingTable, object)
    Tk_DeleteAllBindings(bindingTable, object)
    Tk_BindEvent(bindingTable, eventPtr, tkwin, numObjects, objectPtr)
  引数 ARGUMENTS
    Tcl_Interp *interp (入力in)
    Tk_BindingTable bindingTable (入力in)
    ClientData object (入力in)
    const char *eventString (入力in)
    const char *script (入力in)
    int append (入力in)
    XEvent *eventPtr (入力in)
    Tk_Window tkwin (入力in)
    int numObjects (入力in)
    ClientData *objectPtr (入力in)
  説明 DESCRIPTION
  KEYWORDS

### NAME

Tk_CreateBindingTable, Tk_DeleteBindingTable, Tk_CreateBinding, Tk_DeleteBinding, Tk_GetBinding, Tk_GetAllBindings, Tk_DeleteAllBindings, Tk_BindEvent — X 行事に対応して記述譜を起動する invoke scripts in response to X events

### SYNOPSIS

#include <tk.h>
Tk_BindingTable
Tk_CreateBindingTable(interp)
Tk_DeleteBindingTable(bindingTable)
unsigned long
Tk_CreateBinding(interp, bindingTable, object, eventString, script, append)
int
Tk_DeleteBinding(interp, bindingTable, object, eventString)
const char *
Tk_GetBinding(interp, bindingTable, object, eventString)
Tk_GetAllBindings(interp, bindingTable, object)
Tk_DeleteAllBindings(bindingTable, object)
Tk_BindEvent(bindingTable, eventPtr, tkwin, numObjects, objectPtr)

### 引数 ARGUMENTS

Tcl_Interp *interp (入力in)
  束縛表内の束縛を起動する時に使う為の解釈実行機能｡又､結果と､束縛手続きからの不都合との持帰りにも使われる｡ Interpreter to use when invoking bindings in binding table. Also used for returning results and errors from binding procedures.

Tk_BindingTable bindingTable (入力in)
  束縛表への字句； 以前のTk_CreateBindingTable 呼出しにより返されてなければならない｡ Token for binding table; must have been returned by some previous call to Tk_CreateBindingTable.

ClientData object (入力in)
  束縛が結合している対象を識別する｡ Identifies object with which binding is associated.

const char *eventString (入力in)
  行事並びを記述する文字列｡ String describing event sequence.

const char *script (入力in)
  束縛が発動された時起動すべきTcl 記述譜｡ Tcl script to invoke when binding triggers.

int append (入力in)
  非零は､ 記述譜があれば束縛の為の既存の記述譜に追記することを意味する; 零は､既存の記述譜を新しいものに置換えることを意味する｡ Non-zero means append script to existing script for binding, if any; zero means replace existing script with new one.

XEvent *eventPtr (入力in)
  bindingTable 内の束縛に合致する X 行事｡ X event to match against bindings in bindingTable.

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.

int numObjects (入力in)
  objectPtrによって指示される対象識別子の個数｡ Number of object identifiers pointed to by objectPtr.

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.

### 説明 DESCRIPTION

これ等の手続函数は束縛を生成し起動する一般用途仕組みを提供する｡束縛はbinding tables の条件内で組織化される｡束縛は binding tables の点から組織化される｡束縛表は束縛の集まりに最近の行事の歴史を加えて構成される｡束縛表内で束縛は objects と結合している｡対象の意味は束縛の梱包の依頼元によって定義されている｡譬えば､ Tk は､ bind 命令によって作成された束縛の全てを保有する為に一つの束縛表の使用を続ける｡この表の為に､対象は､窓の名前､級の名前､ all.の様な束縛札の様な文字列へのポインターである｡ Tk は又､それぞれの画布の部品の為の別々の束縛を保有しており､それは画布の bind 部品命令によって生成された束縛を管理している; この表の中に､対象が画布項目又は Tk_Uid 識別札の為の内部構造へのポインターである｡ These procedures provide a general-purpose mechanism for creating and invoking bindings. Bindings are organized in terms of binding tables. A binding table consists of a collection of bindings plus a history of recent events. Within a binding table, bindings are associated with objects. 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 bind command. For this table, objects are pointers to strings such as window names, class names, or other binding tags such as all. Tk also keeps a separate binding table for each canvas widget, which manages bindings created by the canvas's bind 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.

手続函数 Tk_CreateBindingTable は新しい束縛表を作成し､それと interp を結合する(表内の束縛が起動された時､その記述譜が interp 内で評価される)｡ Tk_CreateBindingTable はその表の字句結果を返す､それは､ Tk_CreateBinding or Tk_BindEvent.の様な他の手続函数の呼出しに使われなければならない｡ The procedure Tk_CreateBindingTable creates a new binding table and associates interp with it (when bindings in the table are invoked, the scripts will be evaluated in interp). Tk_CreateBindingTable returns a token for the table, which must be used in calls to other procedures such as Tk_CreateBinding or Tk_BindEvent.

Tk_DeleteBindingTable は束縛表と結合した全ての状態を解放する｡一たび､戻ると､呼出し者は bindingTable 字句結果を再び使うべきではない｡ Tk_DeleteBindingTable frees all of the state associated with a binding table. Once it returns the caller should not use the bindingTable token again.

Tk_CreateBinding は新しい束縛を既存の表に加える｡ object 引数は束縛が結合されている対象を識別する､又､どれかの一語値であるかもしれない｡典型的には､文字列又はデータ構造へのポインターである｡ eventString 引数は結合の為の行事又は行事の並びを識別する; その形式の記述に就いては取扱説明書の bind 命令の項を参照されたい｡ script は束縛が発動した時に評価すべき Tcl 記述譜である｡ append は､ object と eventString の為の束縛が既に実在する場合に何をすべきかを指し示す: もし append が零ならば､ script は古い記述譜を置き替える; もし script が非零であれば新しい記述譜が古いものに追記される｡ Tk_CreateBinding は束縛に結合した全ての行事に関する X の行事篩を返す｡この情報は､適切な行事を選択する為､又は､束縛内の特定の行事の使用を禁止する為に XSelectInput を起動する為には有用であるかもしれない｡もし束縛を生成している間に不都合が生じると(譬えば､ eventString が非実在行事を参照する)､ 0 が返され､不都合伝言文が解釈実行機能 interp.の結果として残される｡ Tk_CreateBinding adds a new binding to an existing table. The object 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 eventString argument identifies the event or sequence of events for the binding; see the documentation for the bind command for a description of its format. script is the Tcl script to be evaluated when the binding triggers. append indicates what to do if there already exists a binding for object and eventString: if append is zero then script replaces the old script; if append is non-zero then the new script is appended to the old one. Tk_CreateBinding returns an X event mask for all the events associated with the bindings. This information may be useful to invoke XSelectInput to select relevant events, or to disallow the use of certain events in bindings. If an error occurred while creating the binding (e.g., eventString refers to a non-existent event), then 0 is returned and an error message is left as the result of interpreter interp.

Tk_DeleteBinding は bindingTable から object とeventString によって与えられた束縛が実在するなら､それを取去る｡ Tk_DeleteBinding は常に TCL_OK を返す｡ある場合には解釈実行機能の結果を刷新し省略時設定の空値にする｡ Tk_DeleteBinding removes from bindingTable the binding given by object and eventString, if such a binding exists. Tk_DeleteBinding always returns TCL_OK. In some cases it may reset the interpreter result to the default empty value.

Tk_GetBinding は eventString と結合した記述譜へのポインターと bindingTable 内の object を返す｡もしその様な束縛が実在しない場合 NULL が返され不都合伝言文が解釈実行機能 interp.の結果として残される｡ Tk_GetBinding returns a pointer to the script associated with eventString and object in bindingTable. If no such binding exists then NULL is returned and an error message is left as the result of interpreter interp.

Tk_GetAllBindings は解釈実行機能 interp の結果として object に結合した bindingTable 内の束縛がある全ての行事文字列のリストを返す｡もし object に関する束縛が実在しない場合結果は空文字列である｡ Tk_GetAllBindings returns in interp's result a list of all the event strings for which there are bindings in bindingTable associated with object. If there are no bindings for object, the result will be an empty string.

Tk_DeleteAllBindings は object に結合した bindingTable 内の全ての束縛を削除する｡ Tk_DeleteAllBindings deletes all of the bindings in bindingTable that are associated with object.

Tk_BindEvent は行事を処理する為に呼ばれる｡それは束縛上に結合した内部の履歴リスト内の行事の複写を作る､次に行事に合致する束縛を検査する｡ Tk_BindEvent は objectPtr によって指されるそれぞれの対象を順番に処理する｡それぞれの対象の為に､現在の行事履歴に合致する全ての束縛を見付け､ bind の為の説明に記述された優先順位の仕組みを使った最も特別な束縛を選択して､その束縛の為の記述譜を起動する｡もし特定の対象の為に合致する束縛がない場合､対象は飛越される｡ Tk_BindEvent は､不都合や bind に関する説明内に記載された様な break や continue の例外を処理しながら､全ての対象を通して続ける｡ Tk_BindEvent 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. Tk_BindEvent processes each of the objects pointed to by objectPtr 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 bind, and invokes the script for that binding. If there are no matching bindings for a particular object, then the object is skipped. Tk_BindEvent continues through all of the objects, handling exceptions such as errors, break, and continue as described in the documentation for bind.

### KEYWORDS

binding, event, object, script
Copyright © 1994 The Regents of the University of California.
Copyright © 1994-1996 Sun Microsystems, Inc.