# tko::state(n) -- widget state handling

*   [SYNOPSIS](#SYNOPSIS)
*   [DESCRIPTION](#DESCRIPTION)  
*   [FUNCTIONS](#FUNCTIONS)  
*   [SEE ALSO](#SEE-ALSO)  
*   [KEYWORDS](#KEYWORDS)  
*   [COPYRIGHT](#COPYRIGHT)  

<a name="SYNOPSIS"></a>
## SYNOPSIS

[**::tko::state commandsadd**](#tko::state-commandsadd) *name ?command? ..*

[**::tko::state commandsget**](#tko::state-commandsget) *name ?pattern?*

[**::tko::state commandsdel**](#tko::state-commandsdel) *name ?pattern?*

[**::tko::state namedel**](#tko::state-namedel) *?pattern?*

[**::tko::state nameset**](#tko::state-nameset) *name value commandlist*

[**::tko::state nameget**](#tko::state-nameget) *?pattern?*

[**::tko::state valueget**](#tko::state-valueget) *name*

[**::tko::state valueset**](#tko::state-valueset) *?..?*

<a name="DESCRIPTION"></a>
## DESCRIPTION

The **tko::state** function cann be used to collect, manage and change state informations using state variables.
State variable are unique string values managed by the **tko::state** function.
Each variable has a value.
The value can be every ordinary string.
Normally state values of widgets are p.e. **normal** and **disabled**.
Each state variable can have a list of associated commands.
After changinig the value of an state variable all the associated command will be called with the new value appended.

<a name="FUNCTIONS"></a>
## FUNCTIONS

<a name="tko::state-commandsadd"></a>
**tko::state commandsadd** *name ?command? ..*

> Bind all the given *command* to changes in a state variable *name*.
All given *command* will be called with the current value of the state variable.
If the state variable *name* not exists an error is thrown.

<a name="tko::state-commandsget"></a>
**tko::state commandsget** *name ?pattern?*

> Return a list of commands bound to the given state variable *name* and
glob style matching the given *pattern*.
If no pattern is given it defaults to "\*".
If the state variable *name* not exists an error is thrown.

<a name="tko::state-commandsdel"></a>
**tko::state commandsdel** *name ?pattern?*

> Delete all commands glob style matching the given *pattern* from the given
state variable *name*.
If no pattern is given it defaults to "\*".
If the state variable *name* not exists an error is thrown.

<a name="tko::state-namedel"></a>
**tko::state namedel** *?pattern?*

> Delete all state variable glob style matching the given *pattern*.
Return the list of the remaining state variables.

<a name="tko::state-nameset"></a>
**tko::state nameset** *name value commandlist*

> Define a new state variable *name* with an initial *value* and a
*commandlist* of commands.
All given commands from *commandlist* will be called with the given *value*.
If there is an error no state variable will be defined.

<a name="tko::state-nameget"></a>
**tko::state nameget** *?pattern?*

> Return a list of used state variables.

<a name="tko::state-valueget"></a>
**tko::state valueget** *value*

> Return the current value of the given state variable *name*.

<a name="tko::state-valueset"></a>
**tko::state valueset** *?name value? ..*

> Call all defined commands of the given state variables *name* with the
given *value*.
The given *value* will be saved for further usage.
If no value is given then call the commands with the current value.

> For each not existing state variable *name* or for each failing call
of a command with the new *value* an error line will be appended to
the return value.
An empty return value indicate success.

<a name="SEE-ALSO"></a>
## SEE ALSO

[tko][] [bind][]

<a name="KEYWORDS"></a>
## KEYWORDS

binding

<a name="COPYRIGHT"></a>
## COPYRIGHT

&copy; 2021- Rene Zaumseil <r.zaumseil@freenet.de>

BSD style license.

[tko]: <https://chiselapp.com/user/rene/repository/tko/home>
[bind]: <https://www.tcl.tk/man/tcl/TkCmd/bind.htm>

