NAME
DynamicHelp - Provide help to Tk or Slab widget
COMMAND
DynamicHelp::add widget ?option value ...?
DynamicHelp::configure ?option ?value ?option value ...???
DynamicHelp::delete widget
DynamicHelp::Helper ?create? instance ?option value ...?
instance attach path subpath ?tagOrItem?
instance cget option
instance configure ?option ?value ?option value ...???
LEGACY COMMAND
DynamicHelp::include class type
DynamicHelp::register path type ?arg...?



DESCRIPTION

When the user allows the pointer to hover over a widget, DynamicHelp can provide help in two forms - either "balloon help" or "variable help". In balloon help, a window is posted that displays help text until the pointer is moved. In variable help, the help string is written to a variable, which is typically the -textvariable for a label or other widget.

Some Slab widgets (ArrowButton, Button, ComboBox, Entry, Label, LabelEntry, ListBox items, MainFrame menus, NoteBook pages, SpinBox, and Tree) have DynamicHelp built in, and it is used via the widget options -helpcmd, -helptext, -helptype, and -helpvar. The widgets that have been ported to Snit and have built-in DynamicHelp delegate to a Snit Abstract Type Slab::DynamicHelp::Helper, and access DynamicHelp exclusively via this object, except that the command DynamicHelp::configure can be used to configure the properties of the help balloon. (The Tree widget has built-in DynamicHelp, has not been ported to Snit, and accesses DynamicHelp via the commands DynamicHelp::add and DynamicHelp::include.)

Here is the use of DynamicHelp in the Entry widget:

snit::widgetadaptor Slab::Entry {

    # Delegate help-related options and methods.
    component MyDynamicHelper
    delegate option -helptext to MyDynamicHelper
    delegate option -helpvar  to MyDynamicHelper
    delegate option -helpcmd  to MyDynamicHelper
    delegate option -helptype to MyDynamicHelper
    delegate method  dynamichelp_for_snit to MyDynamicHelper

    constructor {args} {
        installhull using entry

        # Define and configure component MyDynamicHelper.
        install MyDynamicHelper using Slab::DynamicHelp::Helper ${selfns}::keepDynHelpOpts \
                -helptype balloon
        $MyDynamicHelper attach $win $win

        $self configurelist $args

        # The rest of the constructor ...
        ...
    }
}

DynamicHelp can be added to any other Tk or Slab widget by the command DynamicHelp::add.



COMMAND
DynamicHelp::add widget ?option value ...?

This command adds dynamic help to the given widget.

-command
If specified, refers to a command to execute to get the help text to display. The command must return a string to display. If the command returns an empty string, no help is displayed.
-index
If specified, refers to a menu index to bind the help to instead of a widget. If -type is not menu, this option is ignored.
-item
If specified, refers to an item or tag on a canvas widget or to a tag in a text widget to bind the help to instead of to a widget.
-type
Specifies the type of help. Can be: balloon, variable or menu. Default is balloon.
-text
The text to be displayed as help.
-variable
Specifies a variable name to which the help string will be written. Some other widget (e.g., a status bar) is responsible for displaying this variable.

Creating dynamic help for a menu is a two-step process. The menu itself must first be added and then each menu entry must be added separately. Here is a brief example.

    # create menu
    menu .m -type menubar
    # associate menubar to toplevel BEFORE DynamicHelp::register
    # to make it works with menu clone name
    . configure -menu .m
    .m add cascade -label "File" -menu .m.file
    menu .m.file
    .m.file add command -label "Open..."
    .m.file add command -label "Quit"
    # create label for help, using variable varinfo
    label .l -textvariable varinfo
    # associate all entries of menu .m.file to variable varinfo
    DynamicHelp::add .m.file -type menu -variable varinfo
    # then declare entries of .m.file
    DynamicHelp::add .m.file -type menu -index 0 -text "Detach menu"
    DynamicHelp::add .m.file -type menu -index 1 -text "Open a file"
    DynamicHelp::add .m.file -type menu -index 2 -text "Exit demo"
    
DynamicHelp::configure ?option ?value ?option value ...???
This command configures the balloon help. These balloon properties apply to all cases of balloon help, and are independent of the target widget or the way the balloon help was added to it.

-borderwidth or -bd
Width of the black border around the balloon.
-delay
Define the delay in millisecond of mouse inactivity before displaying the balloon.
-state
Specifies one of two states for help balloons: normal and disabled.
If state is disabled, help balloons will not be displayed for any registered widget.
-topbackground or -topbg
The background color of the toplevel window created for a balloon.

Other standard options are:
  -background or -bg   -font
  -foreground or -fg   -justify
  -padx   -pady
DynamicHelp::delete widget
Delete all dynamic help for the given widget.
DynamicHelp::Helper ?create? instance ?option value ...?
Constructor for a DynamicHelp::Helper object.

-helpcmd
(unused)
-helptext
The text to be displayed as dynamic help.
-helptype
Value is either "balloon" (help text is written to a popup window) or "variable" (help text is written to a specified variable).
-helpvar
The name of the variable that will be used when the dynamic help has -helptype variable.
instance attach path subpath ?tagOrItem?
Attach the dynamic help provided by instance to the widget path (of which this instance is typically a component), and specifically to its subwidget with Tk window path subpath. The argument tagOrItem is required if the help is attached to a specific tag in a text widget or item in a canvas widget.
instance cget option
Command to return the value of one of the options -helpcmd, -helptext, -helptype, or -helpvar.
instance configure ?option ?value ?option value ...???
Command to configure the instance via its options -helpcmd, -helptext, -helptype, or -helpvar.
LEGACY COMMAND
DynamicHelp::include class type
Used only by Slab widgets that have not been ported to Snit, and therefore use the BWidget base class "Widget". The command gives all widgets of a particular BWidget class the options -helpcmd, -helptext, -helptype, and -helpvar, by which DynamicHelp can be requested without calling DynamicHelp::add.
DynamicHelp::register path type ?arg...?

This command is deprecated. Use DynamicHelp::add instead.

Register a help text to the widget path. type determines the type of the help. Depending on type, other options must be provided.
type options
balloon ?tagOrItem? text
variable ?tagOrItem? varName text
menu varName
menuentry index text

If one of the option is missing or is empty, help is removed for this widget.

If tagOrItem is specified, then path is a canvas or a text. In case of a canvas, tagOrItem is the name of a tag or item on the canvas to which the help will be bound. In case of a text, tagOrItem is the name of a tag on the text to which the help will be bound.

For type other than balloon, varName is typically a variable linked to a label.
For menu, balloon type help is not available. To declare a help for menu, you first declare the menu, and then entries of this menu.
For example:

     # create menu
menu .m -type menubar
# associate menubar to toplevel BEFORE DynamicHelp::register
# to make it works with menu clone name
. configure -menu .m
.m add cascade -label "File" -menu .m.file
menu .m.file
.m.file add command -label "Open..."
.m.file add command -label "Quit"
# create label for help, using variable varinfo
label .l -textvariable varinfo
# associate all entries of menu .m.file to variable varinfo
DynamicHelp::register .m.file menu varinfo
# then declare entries of .m.file
DynamicHelp::register .m.file menuentry 0 "Detach menu"
DynamicHelp::register .m.file menuentry 1 "Open a file"
DynamicHelp::register .m.file menuentry 2 "Exit demo"


Notice that if popup menu is owned by a menubar, you must associate first the menubar to its toplevel. In this case, when you create a menu popup, its clone window is also created, and DynamicHelp::register detects the exitence of the clone window and maps events to it.