component(3itcl)

✨ NAME ✨

itcl::component β€” bestie, this is the one that lets you define components for extendedclass, widget, or widgetadaptor πŸ’–

It lives in section 3itcl of the [incr Tcl] manual, and honestly? It's giving main character energy.

Heads up: parts of this description are "borrowed" from the Tcl extension [snit], because the functionality is mostly identical. Credit where credit is due, periodt. 🫢

πŸ’€ WARNING! πŸ’€

Not me having to say this but: this is new functionality in [incr Tcl] where the API can still change!! 😭 So like… don't build your whole personality on it yet. It might shift under you.


🌸 SYNOPSIS 🌸

public component comp ?-inherit?
protected component comp ?-inherit?
private component comp ?-inherit?

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so the component command is what you use inside an [incr Tcl] extendedclass / widget / widgetadaptor definition to define your components. It's literally the whole point of this page, iykyk. ✨

What it does:

  • Explicitly declares a component called comp πŸ‘‘
  • And automatically defines that component's instance variable for you, no extra work required πŸ’…

🌈 the -inherit option

If you pass the -inherit option, then all unknown methods and options get delegated to this component. Slay.

The name -inherit is lowkey implying that instances of this new type inherit, in a sense, the methods and options of the component. So -inherit yes is equivalent to this:

component mycomp
delegate option * to mycomp
delegate method * to mycomp

Like… that's the whole vibe right there. Obsessed. πŸŽ€


πŸ”₯ KEYWORDS πŸ”₯

component, widget, widgetadaptor, extendedclass


Okay bestie, that's the whole page!! This was component(3itcl) from itcl 4.0, brought to you by [incr Tcl] β€” go forth and define your components, you absolute icon πŸ§šβœ¨πŸ’œ

πŸ“¦ where this page comes from