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 -indicatorcmd is 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 -indicatorcmd is executed with two additional arguments, the entryPath of 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 the itemCreate, add and addchild methods, display items of this type will be created if the -itemtype option 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 the padY option 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 to Tk_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 either single, browse, multiple, or extended; the default value is single. πŸ–±οΈ
  • -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 position 0 indicates the first position, 1 indicates 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 the info method. The application programmer can use the -data option 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 are imagetext, text, and $widget. If this option is not specified, then by default the type specified by this HList widget's -itemtype option is used.
  • -state => state β€” Specifies whether this entry can be selected or invoked by the user. Must be either normal or disabled. πŸ”’

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 $col in your HList widget. bestie, $col is zero-based: 0 is the first column, 1 is 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) β€” width has to be in a form that Tk_GetPixels accepts, fr fr.
    • $hlist->columnWidth($col, -char, nChars) β€” sets the width to the average width that nChars characters of the font take up, using the font given by this HList widget's -font option ✨.

  • $hlist->delete(option, $entryPath) β€” deletes one or more list entries πŸ—‘οΈ. option can 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 $entryPath itself survives, it does not get deleted.
    • siblings β€” deletes every list entry that shares the same parent as the entry named by $entryPath. and again, $entryPath itself 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 by option for the entry identified by $entryPath. option can be any of the values that the add method 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 option at all β†’ returns a list describing every available option for $entryPath (peep Tk::options for info on the format of that list πŸ“‹).
    • option given 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.

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 -header option is set to true, then a header item gets displayed at the top of each column. The $col argument 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 option specified β†’ returns a list describing all of the available options for the header display item (see Tk::options for info on the format of this list).
      • option with 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.

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 -itemtype tells it what type of display item to create; if -itemtype isn't given, then by default the type specified by this HList widget's -itemtype option 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 πŸ™ˆβœ¨. option can 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 πŸ“‚. option can be one of the following:
    • $hlist->indicator(cget, $entryPath, option) β€” if the list entry given by $entryPath has 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 option specified β†’ returns a list describing all of the available options for the indicator display item (see Tk::options for info on the format of this list).
      • option with 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.

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 -itemtype specifies what type of display item should be created; if -itemtype isn't given, then by default the type specified by this HList widget's -itemtype option 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 the entryPath of 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 the entryPath's of its children entries. Don't pass it? Then you get a list of the toplevel entryPath's. Family tree reveal.
  • $hlist->info(data ?,$entryPath?) β€” returns the data associated with $entryPath.
  • $hlist->info(dragsite) β€” returns the entryPath of 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 the entryPath of 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 $entryPath exists. Vibe check: does it exist? Yes or no.
  • $hlist->info(hidden, $entryPath) β€” returns a boolean value telling you whether the list entry $entryPath is hidden or not. πŸ™ˆ
  • $hlist->info(next, $entryPath) β€” returns the entryPath of 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. If entryPath is a toplevel list entry, you get the empty string. No parents, only main character energy. πŸ‘‘
  • $hlist->info(prev, $entryPath) β€” returns the entryPath of 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? undef comes 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 configure option of the display item at the column designated by $col of 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 $col of the entry specified by $entryPath. If you specify no option, you get back a list describing all of the available options for $entryPath (peep Tk::options for the format of that list, iykyk). If you specify an option with no value, 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. Option may have any of the values accepted by the item create method. The exact set of options depends on the value of the -itemtype option 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 $col of the entry specified by $entryPath. There's an optional parameter -itemtype you can use to say what type of display items should be created. If -itemtype isn't specified, then by default the type specified by this HList widget's -itemtype option 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 $col of 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 $col of 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 only from given, only the list entry identified by from gets deselected. With both from and to given, it deselects all of the list entrie(s) between from and to, inclusive, without touching the selection state of elements outside that range. Boundaries respected, periodt.
  • $hlist->selectionGet β€” this is an alias for the infoSelection method.
  • $hlist->selectionIncludes($entryPath) β€” returns 1 if the list entry indicated by $entryPath is currently selected; returns 0 otherwise.
  • $hlist->selectionSet(from?, to?) β€” selects all of the list entrie(s) between from and to, inclusive, without affecting the selection state of entries outside that range. When only from is given, only the list entry identified by from is 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 between 0 and 1; together they describe the horizontal span that's visible in the window. For example, if the first element is .2 and 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 -xscrollcommand option. Math but make it fashion.
  • $hlist->xview($entryPath) β€” adjusts the view in the window so that the list entry identified by $entryPath is aligned to the left edge of the window.
  • $hlist->xview(moveto => fraction) β€” adjusts the view in the window so that fraction of the total width of the HList is off-screen to the left. fraction must be a fraction between 0 and 1.
  • $hlist->xview(scroll => number, what) β€” shifts the view in the window left or right according to number and what. Number must be an integer. What must be either units or pages, or an abbreviation of one of those. If what is units, the view adjusts left or right by number character units (the width of the 0 character) on the display; if it's pages, then the view adjusts by number screenfuls. If number is 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 between 0 and 1. The first element gives the position of the list element at the top of the window, relative to the HList as a whole (so 0.5 means 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 -yscrollcommand option. 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 between 0 and 1: 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 either units or pages. if what is units, the view moves up or down by number lines; if it's pages, 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. [1] if -selectmode is "browse", dragging the mouse pointer over the list entries highlights the entry under the pointer, and the -browsecmd callback gets called with one parameter, the entryPath of the highlighted entry. only one entry can be highlighted at a time β€” monogamy, periodt πŸ’…. the -command callback fires when the user double-clicks a list entry.
  2. [2] if -selectmode is "single", entries only get highlighted by mouse <ButtonRelease-1> events. when a new list entry is highlighted, -browsecmd is called with one parameter indicating the highlighted list entry. the -command callback fires when the user double-clicks a list entry.
  3. [3] if -selectmode is "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, -browsecmd is called with an undefined parameter, and it's on you (well, on the -browsecmd callback) to figure out the exact highlighted selection in the HList. the -command callback fires when the user double-clicks a list entry.
  4. [4] if -selectmode is "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, -browsecmd is called with an undefined parameter, and again it's the callback's job to work out the exact highlighted selection in the HList. the -command callback fires when the user double-clicks a list entry.
  5. [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