Curses:...uestion(3)

πŸ’¬ NAME πŸ’¬

Curses::UI::Dialog::Question β€” the little popup that just asks your user a question, bestie. That's it. That's the whole vibe. ✨

(This one lives in the User Contributed Perl Documentation section, btw πŸŽ€)


🌸 CLASS HIERARCHY 🌸

okay so here's the family tree, and yes it's giving royal lineage πŸ‘‘

 Curses::UI::Widget
    |
    +----Curses::UI::Container
            |
            +----Curses::UI::Window
                    |
                    +----Curses::UI::Dialog::Question

Like, it's a Widget, which is a Container, which is a Window, which is a Question dialog. Slay. πŸ’…


✨ SYNOPSIS ✨

use Curses::UI;
my $cui = new Curses::UI;
my $win = $cui->add('window_id', 'Window');

# The hard way.
# -------------
my $dialog = $win->add(
    'mydialog', 'Dialog::Question',
    -question   => 'How super awesome are you?'
);
$dialog->modalfocus;
$win->delete('mydialog');

# The easy way (see Curses::UI documentation).
# --------------------------------------------
my $value = $cui->question(-question => 'How super awesome are you?');

# or even
my $awesomeness = $cui->question('How super awesome are you?');

Not me showing you the hard way first just so you can appreciate the easy way 😭 fr fr, there's a whole spectrum from "I built the dialog myself, by hand, with $win->add" to "one line and we're done". Pick your fighter. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

Curses::UI::Dialog::Question is your basic question dialog β€” lowkey iconic for how simple it is. The way it works: there's a message on it, a TextEntry answer box, and one or more buttons. That's the whole package πŸŽ€. You use it when you need the user to actually type an answer in response to a question. No cap.

Wanna see it in action? There's a short demo at exampes/demo-widgets in the distribution. (that's spelled exactly how it is in the source, bestie β€” go look there πŸ’–)


πŸ’œ OPTIONS πŸ’œ

  • -title < TEXT > β€” sets the title of the dialog window to TEXT. Your little nameplate. πŸ‘‘
  • -question < TEXT > β€” the question you actually show the user, set to TEXT. And yes, the text can contain newline (\n) characters, so go off with the multi-line questions 🌈.
  • -buttons < ARRAYREF > β€” the buttons.
  • -selected < INDEX > β€” which one's pre-selected.
  • -buttonalignment < VALUE > β€” how the buttons line up.

These options set the buttons that have to be used. For the full explanation you gotta go check the Curses::UI::Buttonbox documentation, iykyk 🧚


πŸ”₯ METHODS πŸ”₯

  • new ( HASH ) β€” makes a new one.
  • layout ( ) β€” does the layout thing.
  • draw ( BOOLEAN ) β€” draws it.
  • focus ( ) β€” focuses it.

All of those are standard methods, bestie β€” Curses::UI::Container has the whole explanation if you want the tea β˜•

  • get ( ) β€” this method calls get on the TextEntry object of the dialog and returns its returnvalue. More deets over in Curses::UI::TextEntry. But β€” and this is the important part β€” if the cancel button was pressed, the return value will be undef. πŸ’€ So like... check for that. Curses::UI::TextEntry has more info.

πŸŽ€ SEE ALSO πŸŽ€

Curses::UI, Curses::UI::Container, Curses::UI::Buttonbox β€” your little reading list, bestie πŸ“


⭐ AUTHOR ⭐

Copyright (c) 2004 Luke Closs <lukec@activestate.com>. All rights reserved.

Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de)

This package is free software and is provided "as is" without express or implied warranty. It may be used, redistributed and/or modified under the same terms as perl itself. 🫢


okay that's the whole page, go ask some questions πŸ’… β€” perl v5.42.2, dated 2023-07-03, mwah 😘

πŸ“¦ where this page comes from