Interactive Tablelist Cell Editing Using the ctext Package
For Tablelist Version 5.13
by
Csaba Nemethi
csaba.nemethi@t-online.deContents
Overview
George Peter Staplin's ctext package is a library extension for Tcl/Tk versions 8.0 or higher, written in pure Tcl/Tk code. It is part of tklib, which has the address
http://core.tcl.tk/tklib
Tablelist supports interactive cell editing with the aid of the ctext widget implemented in the package mentioned above. The steps needed for using this widget for editing the cells of a given column are as follows:
- Register the ctext widget for interactive cell editing by
invoking the
tablelist::addCtext
command described below. - Use the tablelist widget's
columnconfigure
subcommand to set the given column's-editable
option to true and its-editwindow
option to the value returned by the command mentioned above. (These options are supported at cell level, too, with the aid of thecellconfigure
subcommand.)
The tablelist::addCtext
Command
- NAME
tablelist::addCtext
– Register the ctext widget for interactive cell editing- SYNOPSIS
-
tablelist::addCtext ?name?
- DESCRIPTION
- This command registers the ctext widget for interactive cell
editing in tablelist widgets. The optional argument specifies
the name to be used for the ctext widget as the value of the
-editwindow
column or cell configuration option. It may be any string that is different from the Tk core and tile edit window names. The default isctext
. The command returns itsname
argument. - The temporary embedded ctext widget used for
interactive cell editing will be created with its
-padx
and-pady
options set to2
, its-wrap
option set tonone
, and its initial height set to the number of lines contained in it. There is, however, an exception from this rule: If the-wrap
option of the cell's column was set to true and Tk version 8.5 or higher is being used, then the ctext widget's-wrap
option will be set toword
and its initial height will equal the number of display lines (taking into account the line wraps) contained in it. You can use the script corresponding to the-editstartcommand
tablelist configuration option to override the initial settings according to your needs. - If the ctext widget's
-wrap
option was set toword
orchar
(either by Tablelist or from within the above-mentioned script) and Tk version 8.5 or higher is being used, then, whenever its width changes (e.g., due to interactive column resizing), its height will be set automatically to the number of display lines contained in it. (The number of display lines is retrieved with the aid of thecount -displaylines
ctext widget subcommand, introduced in Tk 8.5.) - If the widget callback package Wcb was loaded into
the interpreter (via
package require Wcb
orpackage require wcb
) then the ctext widget's height will be updated automatically whenever text is inserted into or deleted from it, which makes the editing much more user-friendly. This is achieved by using an appropriately defined after-insert
and after-delete
callback for the edit window. You can use the script corresponding to the-editstartcommand
tablelist configuration option to define further callbacks for the ctext widget. (The above-mentioned callback is created viawcb::cbappend
, after returning from that script.) - The
Tab
key is reserved for navigation between the editable cells, but the user can insert a tabulator character into the ctext widget by pressingControl-i
. - Unlike in the case of the other widgets used for
interactive cell editing (except the Tk core text widget), the
Return
andKP_Enter
keys insert a newline character into the ctext widget.Control-j
can also be used for inserting a newline.Control-Return
andControl-KP_Enter
terminate the editing and destroy the edit window. Control-Home
andControl-End
have their well-known text widget-specific bindings, just likeMeta-<
andMeta->
iftk_strictMotif
is false. Again, this is different from the behavior of the other widgets used for interactive cell editing (except the Tk core text widget). For jumping into the first/last editable cell, the user can pressAlt-Home
/Alt-End
orMeta-Home
/Meta-End
(Command-Home
/Command-End
on Mac OS Classic and Mac OS X Aqua).- KEYWORDS
- tablelist, editing, ctext