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::addCtextcommand described below. - Use the tablelist widget's
columnconfiguresubcommand to set the given column's-editableoption to true and its-editwindowoption to the value returned by the command mentioned above. (These options are supported at cell level, too, with the aid of thecellconfiguresubcommand.)
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
-editwindowcolumn 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 itsnameargument. - The temporary embedded ctext widget used for
interactive cell editing will be created with its
-padxand-padyoptions set to2, its-wrapoption 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-wrapoption of the cell's column was set to true and Tk version 8.5 or higher is being used, then the ctext widget's-wrapoption will be set towordand 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-editstartcommandtablelist configuration option to override the initial settings according to your needs. - If the ctext widget's
-wrapoption was set towordorchar(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 -displaylinesctext widget subcommand, introduced in Tk 8.5.) - If the widget callback package Wcb was loaded into
the interpreter (via
package require Wcborpackage 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-insertand after-deletecallback for the edit window. You can use the script corresponding to the-editstartcommandtablelist configuration option to define further callbacks for the ctext widget. (The above-mentioned callback is created viawcb::cbappend, after returning from that script.) - The
Tabkey 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
ReturnandKP_Enterkeys insert a newline character into the ctext widget.Control-jcan also be used for inserting a newline.Control-ReturnandControl-KP_Enterterminate the editing and destroy the edit window. Control-HomeandControl-Endhave their well-known text widget-specific bindings, just likeMeta-<andMeta->iftk_strictMotifis 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-EndorMeta-Home/Meta-End(Command-Home/Command-Endon Mac OS Classic and Mac OS X Aqua).- KEYWORDS
- tablelist, editing, ctext