The scrollutil::scrollednotebook Command

For Scrollutil Version 1.9

by

Csaba Nemethi

csaba.nemethi@t-online.de

Contents

Start page


Quick Reference

NAME
scrollutil::scrollednotebook – Create and manipulate scrollednotebook widgets
SYNOPSIS
package require scrollutil_tile
scrollutil::scrollednotebook pathName ?options?
DESCRIPTION
STANDARD OPTIONS
-cursor  -style
WIDGET-SPECIFIC OPTIONS
-height screenDistance
-padding paddingSpec
-takefocus 0|1|""|command
-width screenDistance
TAB OPTIONS
TAB IDENTIFIERS
WIDGET COMMAND
pathName see tabId
KEYBOARD TRAVERSAL
VIRTUAL EVENTS
FURTHER BINDINGS
KEYWORDS
scrollednotebook, widget, notebook, scrolled

Contents     Start page


Detailed Reference

NAME
scrollutil::scrollednotebook – Create and manipulate scrollednotebook widgets
SYNOPSIS
package require scrollutil_tile
scrollutil::scrollednotebook pathName ?options?
Note that the scrollutil::scrollednotebook command is provided by the Scrollutil_tile package, but not by Scrollutil.
DESCRIPTION
The scrollutil::scrollednotebook command creates a new window named pathName and of the class Scrollednotebook, and makes it into a scrollednotebook widget.  Additional options, described below, may be specified on the command line or in the option database to configure aspects of the scrollednotebook widget such as its width, height, and style.  The scrollutil::scrollednotebook command returns its pathName argument.  At the time this command is invoked, there must not exist a window named pathName, but pathName's parent must exist.
A scrollednotebook is a mega-widget that contains a ttk::notebook within a scrollableframe and supports an arbitrary number of unsqueezed tabs.  Currently not visible tabs can be brought into view by navigating and scrolling with the mouse wheel or keyboard.  An individual tab can be made visible programmatically with the aid of the see subcommand.  It is made sure that the currently selected tab is always visible.
The API of the scrollednotebook widget is nearly identical to that of ttk::notebook.  Apart from the scrollednotebook-specific see subcommand, the Tcl command associated with a scrollednotebook widget provides the same subcommands as the one associated with a ttk::notebook.  Note that the API doesn't provide any command for retrieving the path name of the ttk::notebook widget contained in a scrollednotebook, because there is no need to access that widget directly.  Moreover, using its subcommands instead of those of the scrollednotebook widget would result in an unpredictable behavior.
STANDARD OPTIONS
-cursor  -style
See the ttk_widget manual entry for details on the standard options.  The -style option refers to the style of the ttk::notebook widget contained in the scrollednotebook.  The value of the -tabposition option of the style specified by this Ttk widget option must be one of nw (the default), n (the default for the aqua theme), ne, sw, s, or se.  These values will result in a horizontal tab layout (the scrollednotebook widget doesn't support vertical tab layouts).
The default values of the standard options are:
-cursor "" -style TNotebook
WIDGET-SPECIFIC OPTIONS
Command-Line Name:  -height
Database Name:  height
Database Class:  Height

If present and greater than zero, specifies the desired height for the widget in any of the forms acceptable to Tk_GetPixels.  Otherwise, the widget's height is set to the requested height of the ttk::notebook contained in it (which in turn depends on the maximum height of all panes and tabs), immediately after the scrollednotebook gets mapped.  The default is 0.

Command-Line Name:  -padding
Database Name:  padding
Database Class:  Padding

Specifies the amount of extra space to add around the outside of the ttk::notebook widget contained in the scrollednotebook.  See the ttk_notebook manual entry for details.  The default is an empty string.  Note that if this default value is used then the ttk::notebook widget will be drawn with the external padding specified by the -padding option of the widget's style.

Command-Line Name:  -takefocus
Database Name:  takeFocus
Database Class:  TakeFocus

This option determines whether the scrollednotebook widget accepts the focus during keyboard traversal.  It is almost identical to the standard option of the same name (see the options manual entry for details).  The only difference is that not the scrollednotebook widget itself but the ttk::notebook contained in it will receive the focus during keyboard traversal with the standard keys (Tab and Shift-Tab).  The default is "ttk::takefocus".

Command-Line Name:  -width
Database Name:  width
Database Class:  Width

If present and greater than zero, specifies the desired width for the widget in any of the forms acceptable to Tk_GetPixels.  Otherwise, the widget's width is set to the requested width of the ttk::notebook contained in it (which in turn depends, among others, on the maximum width of all panes and the total width of the tabs), immediately after the scrollednotebook gets mapped.  The default is 10c, which should be overridden with a suitable application-specific value.

TAB OPTIONS
See the ttk_notebook manual entry.
TAB IDENTIFIERS
See the ttk_notebook manual entry.
WIDGET COMMAND
The scrollutil::scrollednotebook command creates a new Tcl command whose name is pathName.  This command may be used to invoke various operations on the widget.  It has the following general form:
pathName option ?arg arg ...?
option and the args determine the exact behavior of the command.  The commands possible for scrollednotebook widgets are the same as those for ttk::notebook widgets (see the ttk_notebook manual entry for details), except that scrollednotebook widgets provide the following additional command:
pathName see tabId
This command adjusts the view in the scrollednotebook's window so that the tab given by tabId becomes visible in it.  Note that when a tab gets selected, this command is automatically invoked for it, in order to make that tab visible.  In addition, the currently selected tab is always kept visible, by invoking this command whenever necessary.
KEYBOARD TRAVERSAL
See the ttk_notebook manual entry.
VIRTUAL EVENTS
As described in the ttk_notebook manual entry, after a new tab of a ttk::notebook is selected, the widget generates a <<NotebookTabChanged>> virtual event.  This holds true for scrollednotebook widgets, too.
The Scrollutil_tile package defines the virtual event <<Button3>> as <Button-3> for all windowing systems and additionally as <Control-Button-1> for Mac OS X/11.  If this event occurs over a tab of a ttk::notebook or scrollednotebook whose disabled widget state flag is not set, and the Tk version is 8.5a2 or later, then the widget generates a <<MenuItemsRequested>> virtual event, by invoking   event generate  with the -data option set to a list consisting of the path name of an empty pop-up menu and the numerical index of the tab in question.  (The support for this option was introduced in Tk 8.5a2.)  If the application creates a binding for this virtual event, the binding script can access the user data as the value of the %d field, with the goal to populate the menu with application-specific entries.  Note that the pop-up menu is posted with a delay of 100 ms, to make sure that it will appear readily populated by the application.

The following example provides a pop-up menu item for closing the tabs of a ttk::notebook or scrollednotebook widget $nb:

bind $nb <<MenuItemsRequested>> { populateMenu %W %d }

proc populateMenu {nb data} {
    foreach {menu tabIdx} $data {}
    $menu add command -label "Close Tab" -command [list $nb forget $tabIdx]
}

See the next section for the description of the virtual event <<NotebookTabMoved>>, which is generated when a ttk::notebook or scrollednotebook tab is moved interactively to a new position.

FURTHER BINDINGS
The Scrollutil_tile package implements the navigation between the tabs of a ttk::notebook or scrollednotebook widget via the mouse wheel as follows:  A mouse wheel tick selects the tab cyclically following/preceding the currently selected one.  On the windowing system aqua, if the Option key is down while the mouse wheel is being rotated then a wheel tick selects the tab whose numerical index is 10 greater/less than that of the currently selected one (modulo the number of tabs).  The same holds true on the windowing systems x11 and win32 if the Tk version is 8.7a4 or later and the mouse wheel is rotated with the Alt key down.
The navigation between the tabs of a ttk::notebook or scrollednotebook widget can also be performed with the keys Right, Left, Control-Tab, and Control-Shift-Tab.
In addition, the Scrollutil_tile package adds support for moving the tabs of a ttk::notebook or scrollednotebook widget with the mouse:  If mouse button 1 is pressed over a tab and then dragged outside that tab, then the mouse cursor takes on the shape of a left/right arrow, indicating that the tab in question is being moved to another position.  This operation ends when mouse button 1 is released, and can be canceled by pressing the Escape key.  In both cases, the mouse cursor is reset to its original value, specified by the -cursor configuration option.  After releasing mouse button 1, the source tab is moved to the position previously pointed to by the arrow (provided that the action was not canceled via Escape).  If the Tk version is 8.5a2 or later then after moving the tab to its new position, the widget generates a <<NotebookTabMoved>> virtual event, by invoking   event generate  with the -data option set to a list consisting of the path name of the widget contained in the source pane and the numerical index of the target tab position.  (The support for this option was introduced in Tk 8.5a2.)  All the above works also for a ttk::notebook with vertical tab layout, with the only difference that for the duration of the drag, the cursor is set to one having the shape of an up/down arrow.
If the widget's disabled state flag is set then none of the above actions occur: the tabs are completely insensitive.
KEYWORDS
scrollednotebook, widget, notebook, scrolled

Contents     Start page