HList(3pm)
β¨ HList(3pm) β¨ β the Tk::HList era π
okay bestie, sit DOWN, because this is Tk::HList, from the User Contributed Perl Documentation section of the manual (yes, HList(3pm), that's the whole vibe). It makes Tix Hierarchial List widgets. Yes, "Hierarchial". That's how it's spelled here. We respect it. π«Ά
πΈ NAME πΈ
Tk::HList β Create and manipulate Tix Hierarchial List widgets. That's it, that's the whole personality. π
π SYNOPSIS π
$hlist = $parent->HList(?options?);
look at her. one line. iconic. β¨
π STANDARD OPTIONS π
these come free with the widget, no notes:
-background-borderwidth-cursor-exportselection-foreground-font-height-highlightcolor-highlightthickness-relief-selectbackground-selectforeground-xscrollcommand-yscrollcommand-width
See Tk::options for details of the standard options. They explain it way better than I can, fr fr. π
π WIDGET-SPECIFIC OPTIONS π
okay so THIS is where the HList girlies get their flavor. Every one of these has a Name, a Class and a Switch, and I'm giving you all three because we don't skip details in this house:
-browsecmdβ Name:browsecmd, Class:BrowseCmd. Specifies a perl/Tk callback to be executed when the user browses through the entries in the HList widget. π-columnsβ Name:columns, Class:Columns. Specifies the number of columns in this HList widget. This option can only be set during the creation of the HList widget and cannot be changed subsequently. So decide NOW bestie, no take-backs. π«-commandβ Name:command, Class:Command. Specifies the perl/Tk callback to be executed when the user invokes a list entry in the HList widget. Normally the user invokes a list entry by double-clicking it or pressing the Return key. β‘-drawbranchβ Name:drawBranch, Class:DrawBranch. A Boolean value to specify whether branch line should be drawn to connect list entries to their parents. πΏ (the tree look!!)-foregroundβ Name:foreground, Class:Foreground, Alias:-fg. [OBSOLETE] Specifies the default foreground color for the list entries.-gapβ Name:gap, Class:Gap. [OBSOLETE] The default distance between the bitmap/image and the text in list entries.-headerβ Name:header, Class:Header. A Boolean value specifying whether headers should be displayed for this HList widget (see the header method below). π-heightβ Name:height, Class:Height. Specifies the desired height for the window in number of characters.-indentβ Name:indent, Class:Indent. Specifies the amount of horizontal indentation between a list entry and its children. Must be a valid screen distance value. π-indicatorβ Name:indicator, Class:Indicator. Specifies whether the indicators should be displayed inside the HList widget. See the indicator method below.-indicatorcmdβ Name:indicatorCmd, Class:IndicatorCmd. Specifies a perl/Tk callback to be executed when the user manipulates the indicator of an HList entry. The-indicatorcmdis triggered when the user press or releases the mouse button over the indicator in an HList entry. By default the perl/Tk callback specified by-indicatorcmdis executed with two additional arguments, theentryPathof the entry whose indicator has been triggered and additional information about the event. The additional information is one of the following strings:<Arm>,<Disarm>, and<Activate>. π₯-itemtypeβ Name:itemType, Class:ItemType. Specifies the default type of display item for this HList widget. When you call theitemCreate,addandaddchildmethods, display items of this type will be created if the-itemtypeoption is not specified . (yes there's a space before that period, I don't make the rules π« )-padxβ Name:padX, Class:Pad. [OBSOLETE] The default horizontal padding for list entries.-padxβ Name:padY, Class:Pad. [OBSOLETE] The default vertical padding for list entries.
β οΈ not me pointing out that thepadYoption lists its switch as-padxβ that's literally what the page says, so I'm leaving it exactly as-is. Take it up with the docs, not me. π
-selectbackgroundβ Name:selectBackground, Class:SelectBackground. Specifies the background color for the selected list entries. π¨-selectborderwidthβ Name:selectBorderWidth, Class:BorderWidth. Specifies a non-negative value indicating the width of the 3-D border to draw around selected items. The value may have any of the forms acceptable toTk_GetPixels.-selectforegroundβ Name:selectForeground, Class:SelectForeground. Specifies the foreground color for the selected list entries. β¨-selectmodeβ Name:selectMode, Class:SelectMode. Specifies one of several styles for manipulating the selection. The value of the option may be arbitrary, but the default bindings expect it to be eithersingle,browse,multiple, orextended; the default value issingle. π±οΈ-sizecmdβ Name:sizeCmd, Class:SizeCmd. Specifies a perl/Tk callback to be called whenever the HList widget changes its size. This method can be useful to implement ``user scroll bars when needed'' features. π-separatorβ Name:separator, Class:Separator. Specifies the character to used as the separator character when intepreting the path-names of list entries. By default the character"."is used. (again: typos preserved, I am but a humble messenger π§)-widthβ Name:width, Class:Width. Specifies the desired width for the window in characters.
π¦ DESCRIPTION π¦
The HList method creates a new window (given by the $widget argument) and makes it into a HList widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the HList widget such as its cursor and relief. π«
The HList widget can be used to display any data that have a hierarchical structure, for example, file system directory trees. The list entries are indented and connected by branch lines according to their places in the hierarchy. π³
Each list entry is identified by an entryPath. The entryPath is a sequence of entry names separated by the separator charactor (specified by the -separator option). An entry name can be any string that does not contain the separator charactor, or it can be the a string that contains only one separator charactor.
For example, when "." is used as the separator charactor, "one.two.three" is the entryPath for a list entry whose parent is "one.two", whose parent is "one", which is a toplevel entry (has no parents).
Another examples: ".two.three" is the entryPath for a list entry whose parent is ".two", whose parent is ".", which is a toplevel entry.
okay so basically the dots ARE the family tree. the separator is the bloodline. iykyk π©Έβ¨
π§ DISPLAY ITEMS π§
Each list entry in an HList widget is associated with a display item. The display item determines what visual information should be displayed for this list entry. Please see Tk::DItem for a list of all display items. When a list entry is created by the itemCreate, add or addchild widget methods, the type of its display item is determined by the -itemtype option passed to these methods. If the -itemtype is omitted, then by default the type specified by this HList widget's -itemtype option is used. π
π WIDGET METHODS π
The HList method creates a widget object. This object supports the configure and cget methods described in Tk::options which can be used to enquire and modify the options described above. The widget also inherits all the methods provided by the generic Tk::Widget class.
The following additional methods are available HList widgets:
πΈ $hlist->add($entryPath ?,option=>value, ...?)
Creates a new list entry with the pathname $entryPath. A list entry must be created after its parent is created (unless this entry is a top-level entry, which has no parent). See also "BUGS" below. This method returns the entryPath of the newly created list entry. The following configuration options can be given to configure the list entry:
-at => positionβ Insert the new list at the position given by position. position must be a valid integer. The position0indicates the first position,1indicates the second position, and so on. π’-after => afterWhichβ Insert the new list entry after the entry identified by afterWhich. afterWhich must be a valid list entry and it mush have the same parent as the new list entry. (mush. yes. keeping it. π)-before => beforeWhichβ Insert the new list entry before the entry identified by beforeWhich. beforeWhich must be a valid list entry and it mush have the same parent as the new list entry.-data => stringβ Specifies a string to associate with this list entry. This string can be queried by theinfomethod. The application programmer can use the-dataoption to associate the list entry with the data it represents. π¦-itemtype => typeβ Specifies the type of display item to be display for the new list entry. type must be a valid display item type. Currently the available display item types areimagetext,text, and$widget. If this option is not specified, then by default the type specified by this HList widget's-itemtypeoption is used.-state => stateβ Specifies whether this entry can be selected or invoked by the user. Must be eithernormalordisabled. π
The add method accepts additional configuration options to configure the display item associated with this list entry. The set of additional configuration options depends on the type of the display item given by the -itemtype option. Please see Tk::DItem for a list of the configuration options for each of the display item types. π
π $hlist->addchild($parentPath, ?option, value, ..., ?)
Adds a new child entry to the children list of the list entry identified by $parentPath. Or, if $parentPath is set to be the empty string, then creates a new toplevel entry. The name of the new list entry will be a unique name automatically generated by the HList widget. Usually if $parentPath is foo, then the entryPath of the new entry will be foo.0, foo.1, ... etc. This method returns the entryPath of the newly created list entry. option can be any option for the add method. See also "BUGS" below. π
π $hlist->anchorSet($entryPath)
Sets the anchor to the list entry identified by $entryPath. The anchor is the end of the selection that is fixed while the user is dragging out a selection with the mouse. β
β¨ $hlist->anchorClear
Removes the anchor, if any, from this HList widget. This only removes the surrounding highlights of the anchor entry and does not affect its selection status.
...and that's where part 1 leaves us, bestie β more of this absolute icon of a widget is coming right up π«Ά
$hlist->columnWidth($col?, -char?, ?width?)β query or set the width of column$colin your HList widget. bestie,$colis zero-based:0is the first column,1is the second, and so on down the line π . Call it with no extra params and it hands you back the current width of that column (in pixels, no cap). But if you pass more params you can set the width instead:$hlist->columnWidth($col, '')β an empty string means "make this column exactly wide enough to fit the widest element in it" π. lowkey important: with this setting the column width can change whenever the elements in that column change their sizes.$hlist->columnWidth($col, width)βwidthhas to be in a form thatTk_GetPixelsaccepts, fr fr.$hlist->columnWidth($col, -char, nChars)β sets the width to the average width thatnCharscharacters of the font take up, using the font given by this HList widget's-fontoption β¨.
$hlist->delete(option, $entryPath)β deletes one or more list entries ποΈ.optioncan be any one of these:allβ nukes every single entry in the HList. With this one you don't even need to pass$entryPath.entryβ deletes the entry named by$entryPath, plus all its offsprings if it has any π.offspringsβ deletes all the offsprings (if any) of the entry named by$entryPath... but$entryPathitself survives, it does not get deleted.siblingsβ deletes every list entry that shares the same parent as the entry named by$entryPath. and again,$entryPathitself is not deleted π.
$hlist->dragsiteSet($entryPath)β sets the dragsite to the list entry identified by$entryPath. the dragsite is what marks the source of a drag-and-drop action. heads up though: drag-and-drop functionality has not been implemented in Tix yet, so it's giving "placeholder era" π.$hlist->dragsiteClearβ removes the dragsite, if there is one, from this HList widget. note that this only strips the surrounding highlights off the dragsite entry β it does not touch its selection status, periodt.$hlist->dropsiteSet($entryPath)β sets the dropsite to the list entry identified by$entryPath. the dropsite marks the target of a drag-and-drop action. same deal as before: drag-and-drop functionality has not been implemented in Tix yet π.$hlist->dropsiteClearβ removes the dropsite, if any, from this HList widget. again, this only removes the surrounding highlights of the dropsite entry and does not affect its selection status π«Ά.
$hlist->entrycget($entryPath, option)β returns the current value of the configuration option given byoptionfor the entry identified by$entryPath.optioncan be any of the values that theaddmethod accepts π.$hlist->entryconfigure($entryPath ?,option?, ?value=>option, ...?)β query or modify the configuration options of the list entry identified by$entryPathβ¨. Here's the vibe check:- no
optionat all β returns a list describing every available option for$entryPath(peepTk::optionsfor info on the format of that list π). optiongiven but with no value β returns a list describing just that one named option (it'll be identical to the matching sublist of what you'd get with no option specified).- one or more option-value pairs β it modifies those option(s) to hold the given value(s), and in this case the method returns an empty string.
- no
option may have any of the values accepted by the add or addchild method. and the exact set of options depends on the value of the -itemtype option that was passed to the add or addchild method back when this list entry was created π
.
$hlist->header(option, $col ?,args, ...?)β manipulates the header items of this HList widget π. If this HList widget's-headeroption is set to true, then a header item gets displayed at the top of each column. The$colargument here must be a valid integer:0= first column,1= second column, ... and so on, iykyk. This method supports the following options:$hlist->header(cget, $col, option)β if the$col-th column has a header display item, returns the value of the specified option of the header item. if the header doesn't exist? error, bestie π.$hlist->header(configure, $col, ?option?, ?value, option, value, ...?)β query or modify the configuration options of the header display item of the$col-th column. the header item must exist, or an error will result π.- no
optionspecified β returns a list describing all of the available options for the header display item (seeTk::optionsfor info on the format of this list). optionwith no value β returns a list describing the one named option (identical to the corresponding sublist of the value you'd get with no option specified).- one or more option-value pairs β modifies the given option(s) to have the given value(s); in this case the method returns an empty string.
- no
option may have any of the values accepted by the header create method, and the exact set of options depends on the value of the -itemtype option passed to the header create method when this display item was created πΈ.
$hlist->header(create, $col, ?-itemtype type? ?option value ...?β creates a new display item as the header for the$col-th column β¨. See also "BUGS" below π. If a header display item already exists for this column, it gets replaced by the new item. An optional parameter-itemtypetells it what type of display item to create; if-itemtypeisn't given, then by default the type specified by this HList widget's-itemtypeoption is used. Extra parameters, in option-value pairs, can be passed in to configure the appearance of the display item. Each option-value pair must be a valid option for this type of display item, or one of the following:-borderwidth => colorβ specifies the border width of this header item.-headerbackground => colorβ specifies the background color of this header item.-relief => typeβ specifies the relief type of the border of this header item.
$hlist->header(delete, $col)β deletes the header display item for the$col-th column ποΈ.$hlist->header(exists, $col)β returns true if a header display item exists for the$col-th column; false otherwise.$hlist->header(size, $col)β if a header display item exists for the$col-th column, returns its size in pixels as a two element list(width, height)π; returns an error if the header display item doesn't exist.
$hlist->hide(option ?,$entryPath?)β makes some entries invisible without deleting them πβ¨.optioncan be one of the following:entryβ hides the list entry identified by$entryPath.
currently only the entry option is supported. other options will be added in the next release, so stay tuned bestie π.
$hlist->indicator(option, $entryPath, ?args, ...?)β manipulates the indicators on the list entries π―. An indicator is usually a small display item (like an image) shown to the left of an entry to signal that entry's status β for example, it might show whether a directory is opened or closed π.optioncan be one of the following:$hlist->indicator(cget, $entryPath, option)β if the list entry given by$entryPathhas an indicator, returns the value of the specified option of the indicator. if the indicator doesn't exist, returns an error π.$hlist->indicator(configure, $entryPath, ?option?, ?value, option, value, ...?)β query or modify the configuration options of the indicator display item of the entry specified by$entryPath. The indicator item must exist, or an error will result.- no
optionspecified β returns a list describing all of the available options for the indicator display item (seeTk::optionsfor info on the format of this list). optionwith no value β returns a list describing the one named option (identical to the corresponding sublist of the value returned if no option is specified).- one or more option-value pairs β modifies the given option(s) to have the given value(s); in this case the method returns an empty string.
- no
option may have any of the values accepted by the indicator create method, and the exact set of options depends on the value of the -itemtype option passed to the indicator create method when this display item was created π¦.
$hlist->indicator(create, $entryPath, ?, -itemtype type? ?option value ...?)β creates a new display item as the indicator for the entry specified by$entryPathβ¨. If an indicator display item already exists for this entry, it will be replaced by the new item. An optional parameter-itemtypespecifies what type of display item should be created; if-itemtypeisn't given, then by default the type specified by this HList widget's-itemtypeoption is used. Additional parameters, in option-value pairs, can be passed to configure the appearance of the display item. Each option-value pair must be a valid option for this type of display item, no exceptions π«Ά.$hlist->indicator(delete, $entryPath)β deletes the indicator display item for the entry given by$entryPathποΈ.$hlist->indicator(exists, $entryPath)β returns true if an indicator display item exists for the entry given by$entryPath; returns false otherwise.
$hlist->indicator(size, $entryPath)
Okay so if there's an indicator display item sitting on the entry that $entryPath points at, this hands you back its size as a two-element list shaped like {width height}. Adorable, right? And if that indicator display item doesn't exist? Error. Sorry bestie, no indicator, no size. π
$hlist->info(option, arg, ...)
This is your lil' detective method β it queries info about the HList widget. option can be any one of these cuties:
$hlist->info(anchor)β returns theentryPathof the current anchor of the HList widget, if there even is one. If the anchor isn't set, you get the empty string back. Awkward silence energy.$hlist->infoBbox($entryPath)β returns a list of four numbers describing the visible bounding box of the entry given by$entryPath. The first two elements are the x and y coordinates of the upper-left corner of the screen area that the entry covers (in pixels, relative to the widget), and the last two are the lower-right corner of that area, also in pixels. If no part of the entry is visible on screen, you get an empty string. If the entry is only partially visible, you get only the visible area of the entry. No lies, no filler. β¨$hlist->info(children ?,$entryPath?)β if you pass$entryPath, you get a list of theentryPath's of its children entries. Don't pass it? Then you get a list of the toplevelentryPath's. Family tree reveal.$hlist->info(data ?,$entryPath?)β returns the data associated with$entryPath.$hlist->info(dragsite)β returns theentryPathof the current dragsite of the HList widget, if there is one. If the dragsite isn't set, you get the empty string.$hlist->info(dropsite)β returns theentryPathof the current dropsite of the HList widget, if there is one. If the dropsite isn't set, you get the empty string.$hlist->info(exists, $entryPath)β returns a boolean value telling you whether the list entry$entryPathexists. Vibe check: does it exist? Yes or no.$hlist->info(hidden, $entryPath)β returns a boolean value telling you whether the list entry$entryPathis hidden or not. π$hlist->info(next, $entryPath)β returns theentryPathof the list entry immediately below this one, if there is one. If this entry is already at the bottom of the HList widget, you get the empty string. Bottom of the list, nothing below, that's just how it is.$hlist->info(parent, $entryPath)β returns the name of the parent of the list entry identified by$entryPath. IfentryPathis a toplevel list entry, you get the empty string. No parents, only main character energy. π$hlist->info(prev, $entryPath)β returns theentryPathof the list entry immediately above this one, if there is one. If this entry is already at the top of the HList widget, you get the empty string.$hlist->info(selection)β returns a list of the selected entries in the HList widget. In scalar context, it returns an anonymous list of the selected entries. And if nothing is selected?undefcomes back in scalar context, and an empty list otherwise. Nobody's selected, it's giving silence. π
$hlist->item(option, ?args, ...?)
This one creates and configures the display items at individual columns of the entries. What extra arguments you pass depends on which option you picked:
$hlist->itemCget($entryPath, $col, option)β returns the current value of the configureoptionof the display item at the column designated by$colof the entry specified by$entryPath.$hlist->itemConfigure($entryPath, $col ?,option?, ?value, option, value, ...?)β query or modify the configuration options of the display item at the column designated by$colof the entry specified by$entryPath. If you specify nooption, you get back a list describing all of the available options for$entryPath(peepTk::optionsfor the format of that list, iykyk). If you specify anoptionwith novalue, the method returns a list describing that one named option β and that list will be identical to the corresponding sublist of the value you'd get if no option were specified. And if you specify one or more option-value pairs, the method modifies the given option(s) to have the given value(s); in that case the method returns an empty string.Optionmay have any of the values accepted by the item create method. The exact set of options depends on the value of the-itemtypeoption passed to the item create method when this display item was created. So like, don't be surprised, bestie.$hlist->itemCreate($entryPath, $col ?,-itemtype=>type? ?,option value ...?)β creates a brand new display item at the column designated by$colof the entry specified by$entryPath. There's an optional parameter-itemtypeyou can use to say what type of display items should be created. If-itemtypeisn't specified, then by default the type specified by this HList widget's-itemtypeoption is used. Additional parameters, in option-value pairs, can be passed in to configure the appearance of the display item. Every single option-value pair must be a valid option for that type of display item β no random options, no exceptions. β¨$hlist->itemDelete($entryPath, $col)β deletes the display item at the column designated by$colof the entry specified by$entryPath. Gone. Poof. Deleted. π$hlist->itemExists($entryPath, $col)β returns true if there is a display item at the column designated by$colof the entry specified by$entryPath; returns false otherwise.
$hlist->nearest(y)
$hlist->nearest(y)
Give it a y-coordinate inside the HList window and this method returns the entryPath of the (visible) HList element nearest to that y-coordinate. Closest visible bestie, found. π«Ά
$hlist->see($entryPath)
Adjusts the view in the HList so the entry given by $entryPath is visible. If the entry is already visible, the method does absolutely nothing β no effect, no drama. If the entry is near one edge of the window, the HList scrolls to bring the element into view at the edge. And otherwise? The HList widget scrolls to center the entry. Main character, center stage. π
$hlist->selection(option, arg, ...)
$hlist->selectionOption(arg, ...)
This method is how you adjust the selection inside a HList widget. It's got several forms, depending on option:
$hlist->selectionClear(?from?, ?to?)β with no extra arguments at all, it deselects all of the list entrie(s) in this HList widget. With onlyfromgiven, only the list entry identified byfromgets deselected. With bothfromandtogiven, it deselects all of the list entrie(s) betweenfromandto, inclusive, without touching the selection state of elements outside that range. Boundaries respected, periodt.$hlist->selectionGetβ this is an alias for theinfoSelectionmethod.$hlist->selectionIncludes($entryPath)β returns1if the list entry indicated by$entryPathis currently selected; returns0otherwise.$hlist->selectionSet(from?, to?)β selects all of the list entrie(s) betweenfromandto, inclusive, without affecting the selection state of entries outside that range. When onlyfromis given, only the list entry identified byfromis selected. Selecting things is self care. π
$hlist->show(option ?,$entryPath?)
Shows the entries that got hidden by the hide method. option can be one of the following:
entryβ shows the list entry identified by$entryPath. Welcome back, bb. πΈ
Currently only the entry option is supported. Other options will be added in future releases. So like, watch this space.
$hlist->xview(args)
This method queries and changes the horizontal position of the information in the widget's window. It can take any of these forms:
$hlist->xviewβ returns a list containing two elements. Each element is a real fraction between0and1; together they describe the horizontal span that's visible in the window. For example, if the first element is.2and the second element is.6, then 20% of the HList entry is off-screen to the left, the middle 40% is visible in the window, and 40% of the entry is off-screen to the right. These are the same values passed to scrollbars via the-xscrollcommandoption. Math but make it fashion.$hlist->xview($entryPath)β adjusts the view in the window so that the list entry identified by$entryPathis aligned to the left edge of the window.$hlist->xview(moveto => fraction)β adjusts the view in the window so thatfractionof the total width of the HList is off-screen to the left.fractionmust be a fraction between0and1.$hlist->xview(scroll => number, what)β shifts the view in the window left or right according tonumberandwhat.Numbermust be an integer.Whatmust be eitherunitsorpages, or an abbreviation of one of those. Ifwhatisunits, the view adjusts left or right bynumbercharacter units (the width of the0character) on the display; if it'spages, then the view adjusts bynumberscreenfuls. Ifnumberis negative then characters farther to the left become visible; if it's positive then characters farther to the right become visible. Negative = left, positive = right, don't mix them up bestie. π¦
$hlist->yview(?args?)
This method queries and changes the vertical position of the entries in the widget's window. It can take any of these forms:
$hlist->yviewβ returns a list containing two elements, both of which are real fractions between0and1. The first element gives the position of the list element at the top of the window, relative to the HList as a whole (so0.5means it's halfway through the HList, for example). The second element gives the position of the list entry just after the last one in the window, relative to the HList as a whole. These are the same values passed to scrollbars via the-yscrollcommandoption. Vertical math, but at least it's honest about it. β¨$hlist->yview($entryPath)β scrolls the view so the entry you name with $entryPath sits right at the top of the window. putting it on top, main character placement β¨$hlist->yview(moveto => fraction)β scrolls so the entry at fraction lands at the top of the window. fraction is a number between0and1:0= the very first entry in the HList,0.33= the entry one-third of the way through the HList, and so on. math girlies rise π$hlist->yview(scroll => number, what)β nudges the view up or down based on number and what. number has to be an integer, no cap π«Ά. what is eitherunitsorpages. if what isunits, the view moves up or down by number lines; if it'spages, it moves by number screenfuls. negative number = earlier entries come into view, positive number = later entries come into view. up and down, we love range π
π¦ BINDINGS π¦
okay so this is the whole "what happens when you touch it" section, and it depends entirely on your -selectmode. buckle up bestie:
- [1] if
-selectmodeis"browse", dragging the mouse pointer over the list entries highlights the entry under the pointer, and the-browsecmdcallback gets called with one parameter, the entryPath of the highlighted entry. only one entry can be highlighted at a time β monogamy, periodt π . the-commandcallback fires when the user double-clicks a list entry. - [2] if
-selectmodeis"single", entries only get highlighted by mouse<ButtonRelease-1>events. when a new list entry is highlighted,-browsecmdis called with one parameter indicating the highlighted list entry. the-commandcallback fires when the user double-clicks a list entry. - [3] if
-selectmodeis"multiple", dragging the mouse pointer over the list entries highlights all the entries under the pointer. however β only a contiguous region of list entries can be selected, no skipping around π. when the highlighted area changes,-browsecmdis called with an undefined parameter, and it's on you (well, on the-browsecmdcallback) to figure out the exact highlighted selection in the HList. the-commandcallback fires when the user double-clicks a list entry. - [4] if
-selectmodeis"extended", dragging the mouse pointer over the list entries highlights all the entries under the pointer, and the user can also make disjointed selections using<Control-ButtonPress-1>β yes queen, pick whatever you want, no contiguous rule here π. when the highlighted area changes,-browsecmdis called with an undefined parameter, and again it's the callback's job to work out the exact highlighted selection in the HList. the-commandcallback fires when the user double-clicks a list entry. - [5] arrow key bindings, keyboard besties stand up:
<Up>arrow key moves the anchor point to the item right on top of the current anchor item.<Down>arrow key moves the anchor point to the item right below the current anchor item.<Left>arrow key moves the anchor to the parent item of the current anchor item.<Right>moves the anchor to the first child of the current anchor item. if the current anchor item doesn't have any children, it moves the anchor to the item right below the current anchor item. (no kids? we're going down instead, iconic behavior π)
π EXAMPLE π
this one's a whole vibe β it shows you how to use an HList to store a file directory structure and react to the user's browse events:
use strict;
use Tk;
use Tk::Label;
use Tk::HList;
my $mw = MainWindow->new();
my $label = $mw->Label(-width=>15);
my $hlist = $mw->HList(
-itemtype => 'text',
-separator => '/',
-selectmode => 'single',
-browsecmd => sub {
my $file = shift;
$label->configure(-text=>$file);
}
);
foreach ( qw(/ /home /home/ioi /home/foo /usr /usr/lib) ) {
$hlist->add($_, -text=>$_);
}
$hlist->pack;
$label->pack;
MainLoop;
label says what you're hovering, HList holds the tree, MainLoop does the rest. chef's kiss π
π BUGS π
so here's the messy part, and no cap it's a little cursed. the fact that the display item at column 0 is implicitly associated with the whole entry is probably a design bug. it was done for backward compatibility purposes, bestie β we're all just living with it π«
the result is that there's a large overlap between the item method and the add, addchild, entrycget and entryconfigure methods. whenever multiple columns exist, the programmer should use ONLY the item method to create and configure the display items in each column; and add, addchild, entrycget and entryconfigure should be used ONLY to create and configure entries. like, that's not a suggestion, that's the rule. do not mix them, i am begging π
π₯ KEYWORDS π₯
Hierarchical Listbox
π SEE ALSO π
Tk::DItem
and that's the whole page, bestie, you made it to the end π«Ά this one came from perl v5.40.1, dated 2025-04-13, and it lives at HList(3pm) in the man pages β go forth and build some absolutely gorgeous hierarchical lists, you've got this πβ¨πΈ
π¦ where this page comes from
- debian trixie: perl-tk 1:804.036+dfsg1-5
- ubuntu questing: perl-tk 1:804.036+dfsg1-5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms