The text widget

In Brief

This is a wrapper around the standard Tk text widget which provides Ttk/Tile focus styles, appropriate for whichever theme is active.

From v0.14, this widget provides an automatic right-click popup menu with standard actions (Cut, Copy, Paste, Undo, Redo, Select All, Clear).

Commands

::tclmacbag::text pathName ?Options?

In general, use standard Tk Text widget options, apart from the following which should not be used:

-borderwidth, -highlightthickness, -background and -bg.

These are handled internally by the metawidget according to the Tile/Ttk theme chosen.

The following additional options are available:

Example

grid [::tclmacbag::text .t -height 25 -width 70 -wrap none -rmargin 15] -row 1 -column 1 -sticky nsew
grid [::tclmacbag::scrollbar .vs -orient vertical -command {.t yview}] -row 1 -column 1 -sticky nse
.t configure -wrap word

Popups

By default, this widget contains bindings to a popup menu with the following menu options (disabled where the option is inappropriate or the data is unavailable): Cut, Copy, Paste, Delete, (Separator), Undo, Redo, (Separator), Select All, Clear.

For display-only widgets, the standard Tk ::text widget (with a focus highlight of 0 pixels) is more appropriate. However, unbinding the menus is as simple as redefining the bindings to Control-ButtonPress-1, ButtonRelease-2 and ButtonRelease-3.

The popups menu first appeared in version 0.14.

Further Information

As is standard, ::tclmacbag::text returns with value of pathName, for ease of use with geometry managers like grid and pack.

From v0.09, the TclMacBag text widget is written using Snit. The result is: $w_Text should no longer be used to control the text portion of this megawidget. Use $w instead.

From v0.14, TclMacBag sets up a virtual event called <<RightClick>> which is <ButtonRelease-3> on all systems except Mac, where it is <Control-ButtonPress-1>. To disable the right-click binding, or replace it with your own, use:

bind $w <<RightClick>> { }