Author: Brian Griffin <[email protected]>
State: Final
Type: Project
Vote: Done
Created: 07-Aug-2021
Post-History:
Keywords: Tk,font,WorldChanged,event
Tcl-Version: 8.6
Tk-Ticket: 3049518
Vote-Summary Accepted 5/0/0
Votes-For: BG, FV, KW, SL, JN
Votes-Against: none
Votes-Present: none
Abstract
This tip proposes adding a virtual event that provides script level access to the WorldChanged callback as defined in the Tk_SetClassProcs C API. This callback, and the proposed virtual event, are used to notify widgets when a font is changed and that the layout of the widget needs to be recalculated. Currently, there is no script level notification of this event, the only access is via the WorldChanged C level callback. See Tk-Ticket 3049518
Rationale
Tk and Ttk widgets currently handle font changes via the WorldChanged callback that each internal widget initiates as part of the widget construction. There is no notification, via callback or event, available at the script level. This is important for any mega-widget, or application that implements any sort of layout algorithm at the script level. This is also true for items on a Canvas that include text. If there is any sizing relationship between these items and other Canvas items, the layout can become incorrect when the font changes its size or shape.
Specification
A new virtual event is defined, <<TkWorldChanged>>
. This event will
be sent to every widget after the C level callback has been made. The
user_data field for this event will have value "FontChanged" in order
to distinquish this "WorldChange" from any other form of
"WorldChanged" that may be implemented in the future, for example, screen
dimension change or screen resolution change.
Reference Implementation
See the tk fossil branch bug-3049518 This implementation has been tested with modifications to the BWidgets NoteBook widget and the Tablelist widget, solving layout issues these mega-widgets currently have whenever a font is (re)configured.
Copyright
This document is placed in the public domain.