CGI::T...t::Menu(3pm)
β¨ NAME β¨
okay so bestie, welcome to CGI::Test::Form::Widget::Menu π
it's the abstract representation of a menu. that's the whole vibe. a menu. iconic.
πΈ SYNOPSIS πΈ
# Inherits from CGI::Test::Form::Widget
literally that's it, she inherits everything from CGI::Test::Form::Widget, no cap π«Ά
π¦ DESCRIPTION π¦
so this class is the abstract representation of a menu β like, the concept of a menu β from which you can choose one or several items. which menu are we talking about? either a popup menu or a scrollable list (and that list can possibly have multiple selections, she's flexible like that π).
there's an interface here for:
- querying the selected items
- getting at the presented labels and their associated values
- and naturally calling
select()orunselect()on items
slay. that's the whole job.
π INTERFACE π
the interface is the same as the one described in CGI::Test::Form::Widget, but with the following additions π
π Attributes π
known_valuesβ a hash reference, recording valid menu values as tuples (value => count), wherecountis set to the number of times the same value gets re-used amongst the proposed options. yes, duplicates are counted, we're being thorough bestie.multipleβ whether the menu allows multiple selections. true/false situation.option_labelsβ a list reference, giving you the labels to choose from, in the order in which they appear. the retained labels are either the content of the<OPTION>elements, or the value of theirlabelattribute, when specified. so like, whichever one she has πββοΈoption_valuesβ a list reference, giving you the underlying values that the user chooses from when he selects labels, in the order in which they appear in the menu. the labels are the aesthetic, the values are the actual receipts.selectedβ a hash reference, whose keys are the selected values. that's it. that's the set.selected_countβ the amount of currently selected items. a number. a count. she's counting.
π Attribute Setting π
selectvalue β mark the option value as selected. ifmultipleis false, any previously selected value is automatically unselected. so it's not a crowd, it's a one-in-one-out club.
note that this takes a value, not a label. do not come in here with a label, bestie, it will not work π
unselectvalue β unselect an option value. but listen β it is not possible to do that on a popup menu. you mustselectanother item to unselect any previously selected one. the popup menu has no chill, it always has a chosen one.
π Menu Probing π
is_selectedvalue β test whether an option value is currently selected or not. and this is not testing a label, it's testing a value β which is what the script will get back eventually. labels are there for human consumption only. the values are what the machine actually eats. iykyk.
π Widget Classification Predicates π
there's an additional predicate here to distinguish between a popup menu (single selection mandatory) and a scrolling list (multiple selection allowed, and may select nothing at all β she can want nothing, that's valid π).
is_popupβ returns true for a popup menu. that's the whole thing. true for popup.
π§ Miscellaneous Features π§
although documented, those features are more targetted for internal use... so like, they're in the group chat but they're not the ones you dm, yk? π
set_selectedvalue, flag β change the selection status of an option value.
you should use theselectandunselectconvenience routines instead of calling this feature. fr fr. this one's the backstage door, use the front one.
π AUTHORS π
- the original author is Raphael Manfredi.
- Steven Hilton was long time maintainer of this module.
- current maintainer is Alexander Tokarev
<tokarev@cpan.org>.
the lineage? immaculate. generations of maintainers. periodt π
β SEE ALSO β
CGI::Test::Form::Widget(3)CGI::Test::Form::Widget::Menu::List(3)CGI::Test::Form::Widget::Menu::Popup(3)
go read those too bestie, they're the whole friend group π
okay and that's a wrap on CGI::T...t::Menu(3pm) β brought to you by perl v5.34.0, dated 2022-06-10, and she's still serving. mwah. go forth and select things π
β¨π¦
π¦ where this page comes from
- debian bookworm: libcgi-test-perl 1.111-2 Β· Artistic-1.0-Perl
- debian trixie: libcgi-test-perl 1.111-2 Β· Artistic-1.0-Perl
- ubuntu noble: libcgi-test-perl 1.111-2 Β· Artistic-1.0-Perl
- ubuntu resolute: libcgi-test-perl 1.111-2 Β· Artistic-1.0-Perl
- ubuntu stonking: libcgi-test-perl 1.111-2 Β· Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms