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 toTEXT. Your little nameplate. π-question < TEXT >β the question you actually show the user, set toTEXT. 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 callsgeton theTextEntryobject of the dialog and returns itsreturnvalue. More deets over inCurses::UI::TextEntry. But β and this is the important part β if the cancel button was pressed, the return value will beundef. π So like... check for that.Curses::UI::TextEntryhas 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
- alpine 3.24: perl-curses-ui-doc 0.9609-r3 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms