Tk_SetClassProcs(3)

πŸ’– NAME πŸ’–

Hey bestie, this is Tk_SetClassProcs(3) from the Tk Library Procedures β€” and it is literally all about registering widget specific procedures. Iconic behavior. ✨

✨ SYNOPSIS ✨

#include <tk.h>

Tk_SetClassProcs(tkwin, procs, instanceData)

πŸŽ€ ARGUMENTS πŸŽ€

  • Tk_Window tkwin (in) β€” token for the window you wanna modify, bestie 🫢
  • const Tk_ClassProcs *procs (in) β€” pointer to the data structure containing widget specific procedures. And listen: the data structure pointed to by procs must be static. Tk keeps a reference to it as long as the window exists, so do not let it ghost away. πŸ’…
  • void *instanceData (in) β€” arbitrary one-word value to pass to widget callbacks. Cute little extra, no cap.

πŸ¦‹ DESCRIPTION πŸ¦‹

Tk_SetClassProcs is called to register a set of procedures that are used as callbacks in different places. That is the whole assignment. πŸ’–

The structure pointed to by procs contains this exact lineup:

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

The size field is used to simplify future expansion of the structure. It should always be set to (literally) sizeof(Tk_ClassProcs). Not a vibe. Not an estimate. Literally that. πŸ‘‘

worldChangedProc is invoked when the system has altered in some way that requires some reaction from the widget. For example, when a font alias (see the font manual entry) is reconfigured, widgets configured to use that font alias must update their display accordingly. 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-word value, same main character energy πŸ”₯

createProc is used to create platform-dependent windows. It is invoked by Tk_MakeWindowExist. 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 createProc should return the created window. Slay, give us the window πŸ’…

modalProc is invoked after all bindings on a widget have been triggered in order to handle a modal loop. 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. Very event. Much struct. πŸ¦‹

πŸ‘‘ KEYWORDS πŸ‘‘

  • callback
  • class

Cute little sign-off: this page is serving Tk 8.4 realness, footer edition: Tk 8.4 and Tk_SetClassProcs(3) β€” no date shown, just that classic footer energy. Bye bestie, go register those widget procs responsibly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from