Tk_CanvasTextInfo(3tk)
β¨ Tk_CanvasTextInfo β¨
okay bestie, welcome to Tk_CanvasTextInfo from the Tk Library Procedures π
this one's all about the extra info you need when your canvas items are doing text β think selection drama, input focus, blinking cursors, the whole main character situation π
πΈ NAME πΈ
Tk_CanvasTextInfo β additional information for managing text items in canvases π
π SYNOPSIS π
#include <tk.h>
Tk_CanvasTextInfo *
Tk_CanvasGetTextInfo(canvas)
π¦ ARGUMENTS π¦
Tk_Canvas canvas(in) β a token that identifies a particular canvas widget. it's giving "which canvas are we talking about" energy fr fr
π DESCRIPTION π
so like, textual canvas items? lowkey more complicated to manage than the other items π because of things like the selection and the input focus. that's just the vibe.
Tk_CanvasGetTextInfo can be called by a type manager to grab the extra info it needs for items that display text. the return value is a pointer to a structure that's shared between Tk and all the items that display text π«Ά no cap. the structure looks like this:
typedef struct {
Tk_3DBorder selBorder;
int selBorderWidth;
XColor *selFgColorPtr;
Tk_Item *selItemPtr;
Tcl_Size selectFirst;
Tcl_Size selectLast;
Tk_Item *anchorItemPtr;
Tcl_Size selectAnchor;
Tk_3DBorder insertBorder;
int insertWidth;
int insertBorderWidth;
Tk_Item *focusItemPtr;
int gotFocus;
int cursorOn;
} Tk_CanvasTextInfo;
let's go field by field, bestie, because every single one of these matters π
selBorderβ identifies aTk_3DBorderthat you should use for drawing the background under selected text β¨selBorderWidthβ the width, in pixels, of the raised border around selected text.selFgColorPtrβ points to anXColordescribing the foreground color to use when drawing selected text π¨selItemPtrβ points to the item that's currently selected, orNULLif there's no item selected, or if the canvas doesn't have the selection πselectFirstandselectLastβ the indices of the first and last selected characters inselItemPtr, exactly as returned by theindexProcfor that item.anchorItemPtrβ points to the item that currently has the selection anchor. heads up: this is not necessarily the same asselItemPtrπselectAnchorβ an index identifying the anchor position withinanchorItemPtr.insertBorderβ contains aTk_3DBorderto use when drawing the insertion cursor.insertWidthβ the total width of the insertion cursor in pixels.insertBorderWidthβ the width of the raised border around the insertion cursor.focusItemPtrβ identifies the item that currently has the input focus, orNULLif there's no such item.gotFocusβ1if the canvas widget has the input focus, and0otherwise.cursorOnβ1if the insertion cursor should be drawn infocusItemPtr, and0if it should not be drawn. Tk toggles this field on and off to make the cursor blink β¨ iconic behaviour honestly
the structure returned by Tk_CanvasGetTextInfo is shared between Tk and the type managers π typically the type manager calls Tk_CanvasGetTextInfo once when an item is created, then saves the pointer in the item's record. Tk will update the info in the Tk_CanvasTextInfo for you β for example, a configure widget command might change the selBorder field, or a select widget command might change the selectFirst field, or Tk might change cursorOn so the insertion cursor flashes on and off during successive redisplays π«
β οΈ okay important one, bestie: type managers should treat all the fields of theTk_CanvasTextInfostructure as read-only β with exactly four exceptions:selItemPtr,selectFirst,selectLast, andselectAnchor. that's the whole list, don't get creative π
type managers may change selectFirst, selectLast, and selectAnchor to adjust for insertions and deletions in the item β but only if the item is the current owner of the selection or anchor, as determined by selItemPtr or anchorItemPtr π. and if all the selected text in the item gets deleted, the item should set selItemPtr to NULL to indicate there's no longer a selection. periodt. π
π₯ KEYWORDS π₯
canvas, focus, insertion cursor, selection, selection anchor, text
and that's the whole page, gorgeous π«Ά this was Tk version 4.0, dated with Tk_CanvasTextInfo(3tk) β go forth and manage your text items, you've absolutely got this πβ¨
π¦ where this page comes from
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms