Tk_SetClassProcs(3tk)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– Tk_SetClassProcs β€” register widget specific procedures πŸ’–

okay bestie, gather round, because this is a Tk Library Procedure and it's genuinely iconic. It's called Tk_SetClassProcs and it lives in the 3tk manual section. Let's get into it 🫢


✨ NAME ✨

Tk_SetClassProcs β€” register widget specific procedures


🌸 SYNOPSIS 🌸

#include <tk.h>

Tk_SetClassProcs(tkwin, procs, instanceData)

πŸŽ€ ARGUMENTS πŸŽ€

  • Tk_Window tkwin (in) β€” the token for the window you wanna modify, no cap.
  • const Tk_ClassProcs *procs (in) β€” a pointer to the data structure holding your widget specific procedures. > ⚠️ okay listen, this one matters: the data structure that procs points at must be static. Tk keeps a reference to it for as long as the window exists, so if you let it go out of scope it's giving πŸ’€. Don't do that to yourself.
  • void *instanceData (in) β€” an arbitrary one-word value that gets passed along to your widget callbacks. It's your little care package, iykyk.

πŸ¦‹ DESCRIPTION πŸ¦‹

Tk_SetClassProcs is what you call to register a set of procedures that get used as callbacks in different places. Very main character energy of it.

The structure that procs points to contains the following:

typedef struct {
    Tcl_Size size;
    Tk_ClassWorldChangedProc *worldChangedProc;
    Tk_ClassCreateProc *createProc;
    Tk_ClassModalProc *modalProc;
} Tk_ClassProcs;

The size field exists to make future expansion of the structure easy β€” it's the lowkey genius move. It should always be set to (literally) sizeof(Tk_ClassProcs).


πŸ’« worldChangedProc πŸ’«

worldChangedProc gets invoked when the system has altered in some way that requires some reaction from the widget. For example, when a font alias (peep the font manual entry) is reconfigured, widgets configured to use that font alias have to update their display accordingly. Slay, keep up πŸ’…

worldChangedProc should have arguments and results that match the type Tk_ClassWorldChangedProc:

typedef void Tk_ClassWorldChangedProc(
        void *instanceData);

The instanceData parameter passed to the worldChangedProc will be identical to the instanceData parameter passed to Tk_SetClassProcs. Same one, fr fr.


🌈 createProc 🌈

createProc is used to create platform-dependent windows. It gets invoked by Tk_MakeWindowExist. Obsessed with a handoff honestly.

createProc should have arguments and results that match the type Tk_ClassCreateProc:

typedef Window Tk_ClassCreateProc(
        Tk_Window tkwin,
        Window parent,
        void *instanceData);

The tkwin and instanceData parameters will be identical to the tkwin and instanceData parameters passed to Tk_SetClassProcs. The parent parameter will be the parent of the window to be created. And the createProc should return the created window β€” that's its whole job, periodt.


⭐ modalProc ⭐

modalProc gets invoked after all bindings on a widget have been triggered, in order to handle a modal loop. It's the cleanup-bestie of the group.

modalProc should have arguments and results that match the type Tk_ClassModalProc:

typedef void Tk_ClassModalProc(
        Tk_Window tkwin,
        XEvent *eventPtr);

The tkwin parameter to modalProc will be identical to the tkwin parameter passed to Tk_SetClassProcs. The eventPtr parameter will be a pointer to an XEvent structure describing the event being processed. 🌸


πŸ‘‘ KEYWORDS πŸ‘‘

callback, class


and that's the whole page, bestie β€” you ate it πŸ’–

this was pulled straight from Tk 8.4, and the page itself is Tk_SetClassProcs(3tk). mwah, go forth and register your procs πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from