ntextBindings(n)
π ntextBindings(n) β Alternative Bindings for the Text Widget π
okay bestie, this is the manual page for ntextBindings(n) from tklib, and weβre folding that manual name right in near the top like a lil name tag π«Ά. Itβs all about giving your Tk text widget a glow-up with a binding tag called Ntext.
β¨ NAME β¨
ntextBindings β Alternative Bindings for the Text Widget. Thatβs the whole name, no cap π
.
πΈ SYNOPSIS πΈ
package require Tcl 8.5
package require Tk 8.5
package require ntext ?1.0?
π¦ DESCRIPTION π¦
So the ntext package hands you a binding tag named Ntext for use by text widgets in place of the default Text binding tag.
The Text binding tag provides around one hundred bindings to the text widget (the exact number is platform-dependent, iykyk). A few of these behave in a way that is different from most contemporary text-editing applications. Ntext aims to provide more familiar behaviour. Periodt.
Features of the Ntext bindings that differ from the default Text bindings:
- Clicking near the end of a (logical) line moves the cursor to the end of that line (not the start of the next line). If the widget is in
-wrap wordmode, the same rule applies to display lines. - Double-clicking or dragging near the end of a (logical) line will highlight/select characters from the end of that line (not the next line, or the region at the end of the line where there are no characters). If the widget is in
-wrap wordmode, the same rule applies to display lines. - On windowing systems other than macOS Aqua, the Home key implements "Smart Home" (successive keypresses move the cursor to the start of the display line, then to the first non-whitespace character at the start of the logical line, then toggles between the beginning and end of leading whitespace); the End key implements "Smart End" (which is similar to "Smart Home"). On macOS Aqua, this functionality is provided by the operations
<Command-Left>and<Command-Right>. - When a selection exists, a "Paste" operation (e.g.
<Control-v>) overwrites the selection (as most editors do), and does so on all platforms. - On windowing systems other than macOS Aqua, the Insert key toggles between "Insert" and "Overwrite" modes for keyboard input. (In contrast, the
Textbinding tag uses Insert as a method to paste the "primary selection", a task that can be accomplished instead by mouse middle-click.) - The Escape key clears the selection.
- On the macOS Aqua windowing system,
Ntextfollows Aqua conventions for keyboard navigation. Certain bindings related to vertical scrolling can be forced to behave in the same way as for the Windows and X11 windowing systems, by setting::ntext::classicParagraphsto1(see Section CONFIGURATION OPTIONS). - On the macOS Aqua windowing system,
Ntextfollows Aqua conventions for placement of the insert mark when keyboard navigation cancels a selection. This behavior can be switched off by setting::ntext::classicSelectionto1(see Section CONFIGURATION OPTIONS). - Selecting with
<Shift-Button1>selects from the previous position of the insertion cursor. (In theTextbinding tag, the selection anchor may be the position of the previous mouse click.) <Shift-Button1>operations do not alter the selection anchor. (In theTextbinding tag, they do.)- By default, the
Ntextbinding tag does not provide several of the Control-key bindings supplied by theTextbinding tag. Modern keyboards offer alternatives, such as cursor keys for navigation; modern applications often use the Control-key bindings for other purposes (e.g.<Control-p>for "print").
In the last three cases, the behavior of Text is often useful, so Ntext gives you the option of retaining it, by setting variables defined in the ::ntext namespace to 1 (instead of their default 0). Explaining these features in more detail:
- If the mouse is clicked at position A, then the keyboard is used to move the cursor to B, then shift is held down, and the mouse is clicked at C: the
Textbinding tag gives a selection from A to C;Ntextgives a selection from B to C. If you wantNtextto behave likeTextin this respect, set::ntext::classicMouseSelectto1. - The
Textbinding tag allows successive<Shift-Button-1>events to change both ends of the selection, by moving the selection anchor to the end of the selection furthest from the mouse click. Instead, theNtextbinding tag fixes the anchor, and multiple Shift-Button-1 events can only move the non-anchored end of the selection. If you wantNtextto behave likeTextin this respect, set::ntext::classicAnchorto1. In bothTextandNtext, keyboard navigation with the Shift key held down alters the selection and keeps the selection anchor fixed. - The following "extra"
Textbindings are switched off by default, but can be activated inNtextby setting::ntext::classicExtrasto1:<Control-a>,<Control-b>,<Control-d>,<Control-e>,<Control-f>,<Control-h>,<Control-i>,<Control-k>,<Control-n>,<Control-o>,<Control-p>,<Control-t>,<Control-space>,<Control-Shift-space>.
π CONFIGURATION OPTIONS π
Ntext provides alternatives to a number of behaviours of the classic Text binding tag. Where there is an option, the Ntext behaviour is switched on by default, except for display-line indentation which is discussed on a separate page at ntextIndent.
The behaviour of Ntext may be configured application-wide by setting the values of a number of namespace variables:
::ntext::classicAnchorβ controls whether the anchor point is fixed or variable.0β (default value) selectsNtextbehaviour, i.e. the anchor point is fixed.1β selects classicTextbehaviour, i.e. the anchor point is variable.
::ntext::classicExtrasβ controls those βextraβTextbindings.0β (default value) selectsNtextbehaviour, i.e. several "extra"Textbindings are de-activated.1β selects classicTextbehaviour, i.e. the "extra"Textbindings are activated.
::ntext::classicMouseSelectβ controls the anchor point for mouse selection operations.0β (default value) selectsNtextbehaviour, i.e. the anchor point for mouse selection operations is moved by keyboard navigation.1β selects classicTextbehaviour.
::ntext::classicParagraphsβ controls those macOS Aqua vertical-scrolling bindings.0β (default value) on macOS Aqua, certain keyboard bindings are made to behave in the same way as the Mac application TextEdit. The bindings involve vertical scrolling of the screen and are<?Shift-?Option-(Up|Down)>.1β on macOS Aqua, certain keyboard bindings are made to behave in the same way as for the Windows and X11 windowing systems and the classicText, ignoring the conventions of Aqua. The bindings involve vertical scrolling of the screen and are<?Shift-?Option-(Up|Down)>.
::ntext::classicSelectionβ controls where the insert mark lands when keyboard navigation cancels a selection.0β (default value on macOS Aqua) selects Mac-like behaviour, i.e. when a navigation keystroke cancels a selection, the insert mark first moves to the end of the selection determined by the navigation direction of the keystroke, and then the keystroke is applied.1β (default value except on macOS Aqua) selects PC-like behaviour (the same as classicText), i.e. when a navigation keystroke cancels a selection, the insert mark is not moved before the keystroke is applied.
::ntext::overwriteβ controls insert vs. overwrite typing.0β (initial value) text typed at the keyboard is inserted into the widget.1β text typed at the keyboard overwrites text already in the widget.- The value is toggled by the Insert key.
::ntext::useBlockCursorβ controls whether a block cursor shows up in overwrite mode.0β the block cursor will not be used. When the widget is in overwrite mode (see::ntext::overwrite), the ordinary cursor will change color instead.1β the block cursor will be used when the widget is in overwrite mode (see::ntext::overwrite).- The default value depends on the version of Tk. In versions of Tk earlier than
8.5.12, the sizing of the block cursor had a bug, and::ntext::useBlockCursordefaults to0. From8.5.12onwards the bug is fixed, and::ntext::useBlockCursordefaults to1.
π₯ INTERNALS π₯
In order to remain independent of the version of Tk (8.5 or 8.6), ntext defines its own virtual events. These new virtual events are used only in the Ntext binding tag, and therefore do not interfere with the real or virtual events used in other code.
These events include <<NtextCut>>, <<NtextCopy>>, <<NtextPaste>> which are used in place of <<Cut>>, <<Copy>>, <<Paste>> respectively.
The definition of the virtual event <<NtextCut>> (etc) is similar to that of <<Cut>> (etc) in Tk 8.6.
π BUGS π
This version of ntext is intended to be compatible with all releases of Tk 8.5 and 8.6, and with the branches core-8-5-branch, core-8-6-branch, and trunk in the source code repository for Tk. Any incompatibility with any of these versions, for any Tk windowing system, should be reported as a bug. Please report such in the category ntext of the Tklib Trackers [http://core.tcl.tk/tklib/reportlist].
π EXAMPLE π
To use Ntext but keep classic Text 's variable-anchor feature:
package require ntext
text .t
set ::ntext::classicAnchor 1
bindtags .t {.t Ntext . all}
π SEE ALSO π
bindtags, ntext, ntextIndent, text
β KEYWORDS β
bindtags, text
okay thatβs the page, bestie πβ¨. Cute lil sign-off: source/version is tklib version 1.0, and the footerβs date slot is empty, so no date to report here β the manual name is ntextBindings(n). Bye! π«Άπ
π¦ where this page comes from
- alpine 3.24: tk-lib-doc 0.7-r0 Β· TCL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms