Widget...omboBox(3pm)

πŸ“¦
version 1.997 Β· 2 versions
  • 1.997 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.997 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Widget...omboBox(3pm) β€” Curses::Widgets::ComboBox πŸ’–

okay bestie, sit down, hydrate, because we're talking about Curses::Widgets::ComboBox β€” a lil Perl module from the User Contributed Perl Documentation corner of the manual. It's giving drop-down-menu realness for your terminal, and honestly? iconic. πŸŽ€


🌸 NAME 🌸

Curses::Widgets::ComboBox β€” Combo-Box Widgets. yes, that's it, that's the whole name. slay.


πŸ¦‹ MODULE VERSION πŸ¦‹

$Id: ComboBox.pm,v 1.103 2002/11/03 23:34:50 corliss Exp corliss $

literally the receipts. πŸ’…


✨ SYNOPSIS ✨

so here's the vibe β€” you make one like this:

use Curses::Widgets::ComboBox;

$cb = Curses::Widgets::ComboBox->new({
  CAPTION     => 'Select',
  CAPTIONCOL  => 'yellow',
  COLUMNS     => 10,
  MAXLENGTH   => 255,
  MASK        => undef,
  VALUE       => '',
  INPUTFUNC   => \&scankey,
  FOREGROUND  => 'white',
  BACKGROUND  => 'black',
  BORDER      => 1,
  BORDERCOL   => 'red',
  FOCUSSWITCH => "\t\n",
  CURSORPOS   => 0,
  TEXTSTART   => 0,
  PASSWORD    => 0,
  X           => 1,
  Y           => 1,
  READONLY    => 0,
  LISTITEMS   => [qw(foo bar wop)],
  });

$cb->draw($mwh, 1);

and then, yk, go read the Curses::Widgets pod for all the other methods, because that's where the rest of the lore lives. πŸ“š


🫢 REQUIREMENTS 🫢

you're gonna need all of these, no skipping:

  • Curses
  • Curses::Widgets
  • Curses::Widgets::TextField
  • Curses::Widgets::ListBox

πŸ‘‘ DESCRIPTION πŸ‘‘

Curses::Widgets::ComboBox gives you simplified OO access to Curses-based combo-boxes. periodt.

here's the tea on how it actually behaves: this widget is basically a text field widget at heart, BUT β€” and this is the main character moment β€” when you hit a KEY_DOWN or a "\n", a drop-down list pops up, and whatever item you pick gets dropped right into the text field as the value. it's giving "text field with a secret second personality". 😭


πŸ’… METHODS πŸ’…

⭐ new (inherited from Curses::Widgets)

$cb = Curses::Widgets::ComboBox->new({
  CAPTION     => 'Select',
  CAPTIONCOL  => 'yellow',
  COLUMNS     => 10,
  MAXLENGTH   => 255,
  MASK        => undef,
  VALUE       => '',
  INPUTFUNC   => \&scankey,
  FOREGROUND  => 'white',
  BACKGROUND  => 'black',
  BORDER      => 1,
  BORDERCOL   => 'red',
  FOCUSSWITCH => "\t\n",
  CURSORPOS   => 0,
  TEXTSTART   => 0,
  PASSWORD    => 0,
  X           => 1,
  Y           => 1,
  READONLY    => 0,
  LISTITEMS   => [qw(foo bar wop)],
  });

new spins up a brand new ComboBox object for you. and listen β€” the only mandatory key/value pairs in that config hash are X and Y. everything else is optional and comes with defaults, which I am listing below because I love you:

  • CAPTION β€” default undef β€” caption superimposed on border
  • CAPTIONCOL β€” default undef β€” foreground colour for caption text
  • COLUMNS β€” default 10 β€” number of columns displayed
  • MAXLENGTH β€” default 255 β€” maximum string length allowed
  • MASK β€” default undef β€” not yet implemented
  • VALUE β€” default '' β€” current field text
  • INPUTFUNC β€” default \&scankey β€” function to use to scan for keystrokes
  • FOREGROUND β€” default undef β€” default foreground colour
  • BACKGROUND β€” default undef β€” default background colour
  • BORDER β€” default 1 β€” display a border around the field
  • BORDERCOL β€” default undef β€” foreground colour for border
  • FOCUSSWITCH β€” default "\t\n" β€” characters which signify end of input
  • CURSORPOS β€” default 0 β€” starting position of the cursor
  • TEXTSTART β€” default 0 β€” position in string to start displaying
  • PASSWORD β€” default 0 β€” substitutes '*' instead of characters
  • READONLY β€” default 0 β€” prevents alteration to content
  • LISTLINES β€” default 5 β€” number of lines to display at a time in the drop-down list
  • LISTCOLUMNS[COLUMNS] β€” width of the drop-down list; defaults to the same length specified for the CombBox widget
  • LISTITEMS β€” default [] β€” items listed in drop-down list

some extra notes because details matter, bestie:

  • the CAPTION is only valid when the BORDER is enabled. if the border is disabled, the field will be underlined β€” provided your terminal supports it. πŸ’…
  • if MAXLENGTH is undefined, no limit gets placed on the string length. go wild, I guess. 🌈

πŸŽ€ draw (inherited from Curses::Widgets::TextField)

$cb->draw($mwh, 1);

draw renders the text field in its current state. you must hand it a valid handle to a curses window, because that's where it's gonna render itself. the optional second argument β€” if it's true β€” makes the field's text cursor get rendered too. cute, right? ✨


$combo->popup;

popup makes the drop-down list show up. and since, theoretically, that list should never be seen unless somebody's actively using it, we always assume we need to draw a cursor on the list as well. no cap. πŸ¦‹


πŸ“œ HISTORY πŸ“œ

  • 2001/12/09 β€” First version of the combo box

the origin story. 🍼


(c) 2001 Arthur Corliss (corliss@digitalmages.com)


okay that's the whole page, you ate it, you understood it, you're basically a Curses combo-box sommelier now. πŸ“

so like, this was page Widget...omboBox(3pm) from perl v5.34.0, dated 2022-06-12 β€” and yeah, that's the User Contributed Perl Documentation collection, so go forth and pop up them lists. mwah. πŸ’–πŸ‘‘