Button(3I)

πŸ’– ButtonState, Button, TextButton, PushButton, RadioButton, CheckBox β€” interactive buttons πŸ’–

okay bestie, welcome to the InterViews Reference Manual page for all things button-shaped πŸŽ€ grab a snack, we're doing this properly.


✨ SYNOPSIS ✨

#include <InterViews/button.h>

🌸 DESCRIPTION 🌸

so here's the tea. Button is a whole class of interactors that can set the value of a piece of state. and ButtonState is a class of objects that contain a value plus a list of buttons that can set its value. and that value? it's either an integer or an arbitrary pointer. two options, both iconic, no notes. ✨

TextButton is a subclass of Button that has an associated text label β€” displayed inside the button or to the right of it, dealer's choice. then PushButton, RadioButton and CheckBox are subclasses of TextButton that provide particular displays for buttons. and each kind of button is gonna show itself differently for each of the five possible cases, so let's list them because bestie we do not skip:

  • ``enabled'' β€” when the button is listening to input πŸ‘‚
  • ``disabled'' β€” when the button is not listening πŸ™ˆ
  • ``chosen'' β€” when the button's value is equal to its button state's value πŸ‘‘
  • ``hit'' β€” when a button that is not chosen first receives a DownEvent πŸ’₯
  • ``same-hit'' β€” when a button that is chosen receives a DownEvent πŸ’₯πŸ’₯

so when a button receives a DownEvent, it calls the virtual Refresh() to update its display. then it reads input, just waiting, waiting, waiting for an UpEvent. and if the UpEvent coordinates are also within the button? it calls the virtual Press(). and the default Press operation sets the associated state's value to the button's value. periodt. πŸ’…

oh and one more thing β€” a button can have a list of attached buttons. when a button is not chosen, its attached buttons are ``disabled'', meaning they ignore all input events. like, they're not even looking at you. πŸ«₯


🧸 BUTTONSTATE OPERATIONS 🧸

  • ButtonState()
  • ButtonState(int)
  • ButtonState(void*) β€” Define a button state, optionally with an initial value. ✨
  • void Attach(Button*) β€” Add a button to the list associated with a button state. that button is gonna get notified whenever the button state's value is modified. it's on the list, fr fr. πŸ””
  • void Detach(Button*) β€” Remove a button from the list associated with a button state. bye bestie πŸ¦‹
  • void GetValue(int&)
  • void GetValue(void*&) β€” Get the value of a button. πŸ‘€
  • void SetValue(int)
  • void SetValue(void*) β€” Set the value of a button state and notify all the buttons associated with the state. group chat announcement energy πŸ“£
  • void operator=(ButtonState&) β€” Copy the value of one button state to another. heads up: the button list associated with the source button state is not copied. value only, no plus-ones. 🚫

πŸ’… BUTTON OPERATIONS πŸ’…

  • void PushButton(const char* text, ButtonState* s, int v)
  • void PushButton(const char* text, ButtonState* s, void* v) β€” Construct a button with text in the center and a polygon on the outside. the polygon is like a rectangle but with rounded corners (so, giving very soft-girl geometry 🌸). when chosen, the entire button is drawn with foreground and background colors reversed. main character colorway swap. πŸ”„
  • void RadioButton(const char* text, ButtonState* s, int v)
  • void RadioButton(const char* text, ButtonState* s, void* v) β€” Construct a button with a circle on the left and text on the right. when hit, a second circle is drawn inside the first. when chosen, a filled circle is drawn inside the outer circle. β­•βž‘οΈπŸ”΅
  • void CheckBox(const char* text, ButtonState* s, int on, int off)
  • void CheckBox(const char* text, ButtonState* s, void* on, void* off) β€” Construct a button with a rectangle on the left and text on the right. when hit, a second rectangle is drawn inside the first. when chosen, two diagonal lines are drawn connecting the opposite corners of the rectangle (yes, that's the little check mark, iconic βœ…). and here's the toggle logic, listen closely:
    • when a checkbox is pressed the first time, it sets s to off if the value is on, and sets s to on otherwise.
    • subsequent presses swap the values of the checkbox and s.
  • void Attach(Button*) β€” Add to this button's list of associated buttons. these buttons are enabled when the button is chosen and disabled when it is not chosen. the vibes are conditional, bestie. πŸŽ€
  • void Detach(Button*) β€” Remove a button from this button's list of associated buttons. unfollowed. πŸ’”
  • void Disable() β€” Stop listening to input events. disabled buttons are typically ``grayed out'' by drawing a half-filled rectangle in the background. it's giving unbothered, unavailable. 🌫️
  • void Enable() β€” Start listening to input events. she's back and she's locked in. πŸ”₯
  • void Choose() β€” Make the button as chosen, enabling any associated buttons. πŸ‘‘
  • void Handle(Event&) β€” If the event type is DownEvent and the button is enabled, call Refresh and read events until an UpEvent occurs. if the button is the target of the UpEvent, then call Press. 🎯
  • virtual void Press() β€” Take the appropriate action for the button being pressed. the default is to set the associated state to the button's value, which will trigger all related buttons to update their display. cascade, but make it cute. ✨
  • virtual void Refresh() β€” Update the button display. glow-up on demand. πŸ’«
  • void SetDimensions(int width, int height) β€” Specify the natural size of the button. the default size is a function of the size of the text.
⚠️ this routine is obsolete; use Interactor::Reshape instead. we don't do legacy here bestie, move on πŸ’€
  • void UnChoose() β€” Mark the button as not chosen, disabling any associated buttons. the crown comes off. 🫢

πŸ‘€ SEE ALSO πŸ‘€

  • Event(3I)
  • Interactor(3I)

go read those too, iykyk πŸ¦‹


and that's the whole page, no cap. this absolute banger of a manpage comes to you from InterViews, dated 15 June 1987 ⭐ β€” yes, 1987, and it's still eating. mwah πŸ’–πŸŽ€βœ¨