mentry::mentry
– Create and manipulate multi-entry
widgetsmentry::mentry pathName ?options?
-borderwidth -highlightcolor -relief -highlightbackground -highlightthickness
-background -cursor -font -foreground
-exportselection -insertwidth -selectforeground -insertbackground -invalidcommand -show -insertborderwidth -justify -state -insertofftime -selectbackground -validate -insertontime -selectborderwidth -validatecommand
-body {width ?text
width text ...?}
-disabledbackground
color
-disabledforeground
color
-readonlybackground
color
-takefocus
0|1|""|command
-textvariable
array
number end
pathName adjustentry
index string1 ?string2?
pathName attrib ?name?
?value name value ...?
pathName cget
option
pathName clear first
?last?
pathName configure
?option? ?value option value ...?
pathName entries
pathName entrycount
pathName entrylimit
index
pathName entrypath
index
pathName getarray
array
pathName getlist
pathName getstring
pathName hasattrib
name
pathName isempty
?index?
pathName isfull
?index?
pathName labelcount
pathName labelpath
index
pathName labels
pathName put startIndex
?string string ...?
pathName setentryextrawidth index
amount
pathName setentryfont
index font
pathName setentrywidth
index width
pathName unsetattrib
name
mentry::mentry
– Create and manipulate multi-entry
widgetsmentry::mentry pathName ?options?
mentry::mentry
command creates a new window
named pathName
and of the class
Mentry
, and makes it into a mentry widget.
Additional options, described below, may be specified on the command line
or in the option database to configure aspects of the mentry such as its
colors, font, and components. The mentry::mentry
command returns its pathName
argument. At the
time this command is invoked, there must not exist a window named
pathName
, but pathName
's parent
must exist.-body
configuration option) also
determines the maximal number of characters that can be inserted into
it. This is achieved with the aid of the wcb::callback
command, by registering
the wcb::checkEntryLen
before-insert
callback with the entry component.
In order to keep this callback, additional
before-insert
callbacks (if needed) should only be
registered with the wcb::cbappend
and wcb::cbprepend
commands. When
reaching this limit in an entry having the input focus, the latter is set
automatically to the next enabled entry component, the contents of that
widget is selected, and the insertion cursor is set to its end. This
is made sure by defining an appropriate after-insert
callback, which must be kept to be the last such callback for the
entry. For this reason, additional after-insert
callbacks (if needed) should only be registered with the
wcb::cbprepend
command. The same command should
be used exclusively to define after-motion
callbacks
(if needed), because mentry::mentry
registers one that
must be the last after-motion
callback for each entry
component.mentry::dateMentry
command
has a type
attribute having the value
"Date"
and a format
attribute specifying
the meanings of its components. The values of these attributes are
queried and used in the bodies of the procedures mentry::putClockVal
and
mentry::getClockVal
.-borderwidth -highlightcolor -relief -highlightbackground -highlightthickness
-background -cursor -font -foreground
configure
subcommand of the Tcl command corresponding
to that component. However, applying this method to change the font
of an entry of a tile-based mentry widget might break the latter's
appearance (this has tile-related technical reasons). To avoid this
problem, it is recommended to use the setentryfont
subcommand of the Tcl command
associated with the mentry widget for changing the value of the
-font
option of one of its entry components.-bg
(for -background
) and
-fg
(for -foreground
) are supported
for both classical and tile-based mentry widgets.Arc
, plastik
,
tileqt
, vista
, and
xpnative
), the -background
option
will be ignored for the entry components of a tile-based mentry
widget. The same holds true for the aqua
theme in dark
mode and with some Tk versions in the light appearance, too.-exportselection -insertwidth -selectforeground -insertbackground -invalidcommand -show -insertborderwidth -justify -state -insertofftime -selectbackground -validate -insertontime -selectborderwidth -validatecommand
configure
subcommand of the Tcl command corresponding
to that entry. The options -insertbackground
,
-insertborderwidth
, -insertofftime
,
-insertontime
, -insertwidth
,
-selectbackground
,
-selectborderwidth
, and
-selectforeground
are only supported by the Mentry
package, but not by Mentry_tile. The common abbreviations
-invcmd
(for -invalidcommand
) and
-vcmd
(for -validatecommand
) are
supported for both classical and tile-based mentry widgets.Command-Line Name: | -body |
Database Name: | body |
Database Class: | Body |
Specifies the initial widths of the entry components of the given multi-entry widget, as well as the texts to be displayed in the labels separating the entries. The value of this option is viewed as a list. Each odd-numbered element is interpreted as the value of the
-width
configuration option of an entry component, while each even-numbered element represents the value of the-text
configuration option of a label child. That is, each entry width must be followed by a label text, except for the last one, for which a corresponding label text is optional. The order of the list elements determines the creation order of the components; these will be packed in a row, without any horizontal padding. The initial width of each entry also determines the number of characters that can be inserted into it; this maximal length remains unchanged even if the entry's width is set to a new value later on.The width of an entry component and the text displayed in a label may be changed by using the
configure
subcommand of the Tcl command corresponding to that component. However, applying this method to change the width of of an entry of a tile-based mentry widget might break the latter's appearance (this has tile-related technical reasons). To avoid this problem, it is recommended to use thesetentrywidth
subcommand of the Tcl command associated with the mentry widget for changing the value of the-width
option of one of its entry components.
Command-Line Name: | -disabledbackground |
Database Name: | disabledBackground |
Database Class: | DisabledBackground |
This option specifies the background color to use for all entry and label components of the given multi-entry widget when it is disabled. If the value of this option is an empty string then the normal background color is used. This option is only supported by the Mentry package, but not by Mentry_tile.
Command-Line Name: | -disabledforeground |
Database Name: | disabledForeground |
Database Class: | DisabledForeground |
This option specifies the foreground color to use for all entry and label components of the given multi-entry widget when it is disabled. If the value of this option is an empty string then the normal foreground color is used. This option is only supported by the Mentry package, but not by Mentry_tile.
Command-Line Name: | -readonlybackground |
Database Name: | readonlyBackground |
Database Class: | ReadonlyBackground |
This option specifies the background color to use for all entry and label components of the given multi-entry widget when it is readonly. If the value of this option is an empty string then the normal background color is used. This option is only supported by the Mentry package, but not by Mentry_tile.
Command-Line Name: | -takefocus |
Database Name: | takeFocus |
Database Class: | TakeFocus |
This option determines whether the widget accepts the focus during keyboard traversal. It is almost identical to the standard option of the same name (see the options manual entry for details). The only difference is that not the widget itself but its first enabled entry component will receive the focus during keyboard traversal with the standard keys (
Tab
andShift-Tab
). See the DEFAULT BINDINGS section below for information on how to move the focus from one entry component to another one using the keyboard.
Command-Line Name: | -textvariable |
Database Name: | textvariable |
Database Class: | Variable |
If the value of this option is not an empty string then it must be an array. In this case, for each entry component of the given multi-entry widget the value of the array element with the index of the entry as element name specifies the value of the
-textvariable
option for that entry. The entry indices start with0
. For example, specifying-textvariable arr
for a multi-entry widget having two entry components is equivalent to specifying-textvariable arr(0)
for the first and-textvariable arr(1)
for the second entry of that widget.
number |
Specifies the component as a numerical index, where
0 corresponds to the first entry or label
component. |
end |
Indicates the last entry or label component of the mentry. |
end
can be abbreviated as
en
or e
. Out-of-range indices
are automatically rounded to the nearest legal value.mentry::mentry
command creates a new Tcl command
whose name is pathName
. This command may be
used to invoke various operations on the widget. It has the
following general form:
pathName option ?arg arg ...?
option
and the arg
s determine
the exact behavior of the command. The following commands are
possible for mentry widgets:pathName
adjustentry index string1
?string2?
index
if needed, to make it just large enough for
texts of the entry-specific maximal length, consisting of characters
contained in the string1
argument, excepting at
most one character, which may be contained in the optional
string2
argument. Returns an empty
string."0123456789ABCDEF"
to this subcommand
you can make sure that the entry components will have optimal widths,
just large enough to display not only the decimal digits, but also up
to two letters in the range A
- F
(which need
more room than the decimal digits when using a proportionally-spaced
font). It is recommended to invoke this subcommand even if the
allowed characters are restricted to the digits 0
-
9
only, because in some fonts not all decimal digits have
the same width."0123456789"
as its string1
argument
and "+-"
as its string2
argument,
being that the entry's first character can be not only a decimal digit
but also the sign "+"
or "-"
. (Note
that in most proportional fonts, the width of the "+"
character is larger than that of "0"
.)pathName attrib
?name? ?value name value ...?
name
is specified, the command returns a list of
pairs, each of which contains the name and the value of an attribute
for pathName
. If name
is
specified with no value
, then the command returns
the value of the one named attribute, or an empty string if no
corresponding value exists (you can use the hasattrib
subcommand to distinguish this
case from the one that the value of an existing attribute is an
empty string). If one or more
name
-value
pairs are specified,
then the command sets the given widget attribute(s) to the given
value(s); in this case the return value is an empty string.
name
may be an arbitrary string.pathName cget
option
option
, which may have any of the values accepted
by the mentry::mentry
command.pathName clear
first ?last?
first
and last
are indices specifying the first and last entries in the range to
clear. If last
is not specified then it
defaults to first
, i.e., a single entry is
cleared. The return value is an empty string.pathName configure
?option? ?value option value
...?
option
is specified, the command returns a
list describing all of the available options for
pathName
(see Tk_ConfigureInfo
for information on the format of this list). If
option
is specified with no
value
, then the command returns a list describing
the one named option (this list will be identical to the corresponding
sublist of the value returned if no option
is
specified). If one or more
option
-value
pairs are
specified, then the command modifies the given widget option(s) to have
the given value(s); in this case the return value is an empty
string. option
may have any of the values
accepted by the mentry::mentry
command.pathName
entries
pathName
entrycount
pathName entrylimit
index
index
.pathName entrypath
index
index
.pathName getarray
array
array
having the index of the entry as element
name. The entry indices start with 0
. The
return value is an empty string.pathName
getlist
pathName
getstring
-body
configuration option. That is, the string of the first entry is
followed by the text of the first label, which in turn is followed by
the string of the second entry, and so on.pathName hasattrib
name
1
if the attribute name
exists and 0
otherwise.pathName isempty
?index?
index
is specified then the command returns
the value 1
if the string contained in the entry component
identfied by index
is empty and 0
otherwise. If this optional argument is not present then the
command returns the value 1
if the strings contained in
the entry components of the widget are all empty and 0
otherwise.pathName isfull
?index?
index
is specified then the command returns
the value 1
if the length of the string contained in the
entry component identfied by index
equals the
number of characters that can be inserted into the entry and
0
otherwise. If this optional argument is not
present then the command returns the value 1
if the
lengths of the strings contained in the entry components of the widget
all equal the numbers of characters that can be inserted into the
respective entries (i.e., if all entry components are full) and
0
otherwise.pathName
labelcount
pathName labelpath
index
index
.pathName
labels
pathName put
startIndex ?string string ...?
startIndex
with the corresponding
string
arguments by using the
delete
and insert
operations,
until either the entries or the string
s are
consumed. If one of these subcommands gets canceled by some
before-callback in any entry component then the command restores the
original contents of all affected entries and returns the value
0
, otherwise it returns 1
. In both
cases, the command keeps the position of the insertion cursor in all
entry components.pathName
setentryextrawidth index amount
index
.
amount
may have any of the standard forms for
screen distances (e.g., a number of pixels). The return value is
an empty string.-body
option.pathName
setentryfont index font
index
to the value given by
font
. This is done by invoking the
configure
subcommand of the Tcl command
corresponding to the entry. When using the package Mentry_tile,
this command also performs some additional steps necessary for updating
the appearance of the tile-based mentry widget. The return value
is an empty string.pathName
setentrywidth index width
index
to the number of characters given by
width
. This is done by invoking the
configure
subcommand of the Tcl command
corresponding to the entry. When using the package Mentry_tile,
this command also performs some additional steps necessary for updating
the appearance of the tile-based mentry widget. The return value
is an empty string.-body
option.pathName
unsetattrib name
name
. Returns an
empty string.mentry::mentry
command partially redefines the
bindings of the components of the mentry widget it creates:Left
key clears
the selection in that entry, moves the focus to the previous enabled
entry component, and sets the insertion cursor to the end of that
widget. Similarly, at the end of an entry component that is not
the last enabled entry within the widget, the Right
key
clears the selection in that entry, moves the focus to the next enabled
entry component, and sets the insertion cursor to the beginning of that
widget. If tk_strictMotif
is false then
Control-b
and Control-f
behave the same as
Left
and Right
, respectively.Control-Left
moves the focus to
the previous enabled entry component, selects the contents of that
widget, and sets the insertion cursor to its end; if there is no
enabled entry component to the left of the current one then
Control-Left
moves the insertion cursor to the beginning
of the current entry and clears the selection in that widget.
Similarly, in an entry component that is not the last enabled entry
within the widget, Control-Right
moves the focus to the
next enabled entry component, selects the contents of that widget, and
sets the insertion cursor to its end; if there is no enabled entry
component to the right of the current one then
Control-Right
moves the insertion cursor to the end of the
current entry and clears the selection in that widget. If
tk_strictMotif
is false then Meta-b
and Meta-f
behave the same as Control-Left
and Control-Right
,
respectively.Home
key clears the selection in the
current entry widget, moves the focus to the first enabled entry
component, and sets the insertion cursor to the beginning of that
widget. Similarly, the End
key clears the selection
in the current entry widget, moves the focus to the last enabled entry
component, and sets the insertion cursor to the end of that
widget. If tk_strictMotif
is false then
Control-a
and Control-e
behave the same as
Home
and End
, respectively.Shift-Home
moves the focus to the first
enabled entry component, sets the insertion cursor to the beginning of
that widget, and either extends the selection to that position, or
clears the selection in the current entry and selects the contents of
the new widget, depending upon whether the current entry is the first
enabled entry component or not. Similarly, Shift-End
moves the focus to the last enabled entry component, sets the insertion
cursor to the end of that widget, and either extends the selection to
that position, or clears the selection in the current entry and selects
the contents of the new widget, depending upon whether the current
entry is the last enabled entry component or not.BackSpace
key deletes the selection if
there is one in the current entry. Otherwise, it deletes either
the character to the left of the insertion cursor in the current entry,
or the last character of the previous enabled entry component.
The latter takes place at the beginning of an entry component that is
not the first enabled entry within the widget; in this case, the
BackSpace
key also moves the focus to the previous enabled
entry component and sets the insertion cursor to its end. If
tk_strictMotif
is false then Control-h
behaves the same as BackSpace
.tk_strictMotif
is false then
Meta-d
deletes all characters to the right of the
insertion cursor within the current entry, while
Meta-BackSpace
and Meta-Delete
delete either
all characters to the left of the insertion cursor in the current
entry, or the contents of the previous enabled entry component.
The latter takes place at the beginning of an entry component that is
not the first enabled entry within the widget; in this case,
Meta-BackSpace
and Meta-Delete
also clear the
selection in the current entry widget and move the focus to the
previous enabled entry component.