.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Balloon 3" .TH Balloon 3 2023-07-25 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Tk::Balloon \- pop up help balloons. .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 3 \& use Tk::Balloon; \& ... \& $b = $top\->Balloon(\-statusbar => $status_bar_widget); \& \& # Normal Balloon: \& $b\->attach($widget, \& \-balloonmsg => "Balloon help message", \& \-statusmsg => "Status bar message"); \& \& # Balloon attached to entries in a menu widget: \& $b\->attach($menu, \-state => \*(Aqstatus\*(Aq, \& \-msg => [\*(Aqfirst menu entry\*(Aq, \& \*(Aqsecond menu entry\*(Aq, \& ... \& ], \& ); \& \& # Balloon attached to individual items in a canvas widget: \& $b\->attach($canvas, \-balloonposition => \*(Aqmouse\*(Aq, \& \-msg => {\*(Aqitem1\*(Aq => \*(Aqmsg1\*(Aq, \& \*(Aqtag2\*(Aq => \*(Aqmsg2\*(Aq, \& ... \& }, \& ); \& \& # Balloon attached to items in a listbox widget: \& $b\->attach($listbox, \-balloonposition => \*(Aqmouse\*(Aq, \& \-msg => [\*(Aqfirst listbox element\*(Aq, \& \*(Aq2nd listbox element\*(Aq, \& ... \& ], \& ); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\fBBalloon\fR provides the framework to create and attach help balloons to various widgets so that when the mouse pauses over the widget for more than a specified amount of time, a help balloon is popped up. .SS "Balloons and Menus or Listboxes" .IX Subsection "Balloons and Menus or Listboxes" If the balloon is attached to a \fBMenu\fR or \fBListbox\fR widget and the message arguments are array references, then each element in the array will be the message corresponding to a menu entry or listbox element. The balloon message will then be shown for the entry which the mouse pauses over. Otherwise it is assumed that the balloon is to be attached to the \fBMenu\fR or \fBListbox\fR as a whole. You can have separate status and balloon messages just like normal balloons. .SS "Balloons and Canvases" .IX Subsection "Balloons and Canvases" If the balloon is attached to a \fBCanvas\fR widget and the message arguments are hash references, then each hash key should correspond to a canvas item ID or tag and the associated value will correspond to the message for that canvas item. The balloon message will then be shown for the current item (the one at the position of the mouse). Otherwise it is assumed that the balloon is to be attached to the \fBCanvas\fR as a whole. You can have separate status and balloon messages just like normal balloons. .SS "Balloons and HLists" .IX Subsection "Balloons and HLists" If the balloon is attached to a \fBHList\fR widget and the message arguments are hash references, then each hash key should correspond to a HList path and the associated value will correspond to the message for that HList item. The balloon message will then be shown for the current item (the one at the position of the mouse). Otherwise it is assumed that the balloon is to be attached to the \fBHList\fR as a whole. You can have separate status and balloon messages just like normal balloons. .SS "Balloon Position" .IX Subsection "Balloon Position" By default, the balloon pops up at the lower right side of the client. If it would extend outside the lower screen border, it's positioned at the upper right side. If it would extend outside the right screen border it's shown on the lower left side of the client. If it would extend outside both the lower and the right screen border, it's positioned at the upper left side of the client. Thus, the little arrow always points to the attached client. .SH OPTIONS .IX Header "OPTIONS" \&\fBBalloon\fR accepts all of the options that the \fBFrame\fR widget accepts. In addition, the following options are also recognized. .IP \fB\-initwait\fR 4 .IX Item "-initwait" Specifies the amount of time to wait without activity before popping up a help balloon. Specified in milliseconds. Defaults to 350 milliseconds. This applies to both the popped up balloon and the status bar message. .IP \fB\-state\fR 4 .IX Item "-state" Can be one of \fB'balloon'\fR, \fB'status'\fR, \fB'both'\fR or \fB'none'\fR indicating that the help balloon, status bar help, both or none respectively should be activated when the mouse pauses over the client widget. Default is \fB'both'\fR. .IP \fB\-statusbar\fR 4 .IX Item "-statusbar" Specifies the widget used to display the status message. This widget should accept the \fB\-text\fR option and is typically a \&\fBLabel\fR. If the widget accepts the \fB\-textvariable\fR option and that option is defined then it is used instead of the \fB\-text\fR option. .IP \fB\-balloonposition\fR 4 .IX Item "-balloonposition" Can be one of \fB'widget'\fR or \fB'mouse'\fR. It controls where the balloon will popup. \fB'widget'\fR makes the balloon appear at the lower right corner of the widget it is attached to (default), and \fB'mouse'\fR makes the balloon appear below and to the right of the current mouse position. .IP \fB\-postcommand\fR 4 .IX Item "-postcommand" This option takes a \fBCODE\fR reference which will be executed before the balloon and statusbar messages are displayed and should return a true or false value to indicate whether you want the balloon to be displayed or not. This also lets you control where the balloon is positioned by returning a true value that looks like \fIX,Y\fR (matches this regular expression: \f(CW\*(C`/^(\ed+),(\ed+)$/\*(C'\fR). If the postcommand returns a value that matches that re then those coordinates will be used as the position to post the balloon. \fIWarning:\fR this subroutine should return quickly or the balloon response will appear slow. .IP \fB\-cancelcommand\fR 4 .IX Item "-cancelcommand" This option takes a \fBCODE\fR reference which will be executed before the balloon and statusbar messages are canceled and should return a true or false value to indicate whether you want the balloon to be canceled or not. \fIWarning:\fR this subroutine should return quickly or the balloon response will appear slow. .IP \fB\-motioncommand\fR 4 .IX Item "-motioncommand" This option takes a \fBCODE\fR reference which will be executed for any motion event and should return a true or false value to indicate whether the currently displayed balloon should be canceled (deactivated). If it returns true then the balloon will definitely be canceled, if it returns false then it may still be canceled depending the internal rules. \&\fINote:\fR a new balloon may be posted after the \fB\-initwait\fR time interval, use the \fB\-postcommand\fR option to control that behavior. \&\fIWarning:\fR the subroutine should be extremely fast or the balloon response will appear slow and consume a lot of CPU time (it is executed every time the mouse moves over the widgets the balloon is attached to). .IP \fB\-numscreens\fR 4 .IX Item "-numscreens" This option accepts an integer 1 or greater. This option should be used to avoid disjointed balloons across multiple screens in single logical sceen (SLS) mode. This only currently works in the horizontal direction. Example: If you are running dual screens in SLS mode then you would set this value to 2. Default value is 1. .SH METHODS .IX Header "METHODS" The \fBBalloon\fR widget supports only three non-standard methods: .SS "\fBattach(\fP\fIwidget\fP, \fIoptions\fP\fB)\fP" .IX Subsection "attach(widget, options)" Attaches the widget indicated by \fIwidget\fR to the help system. The allowed options are: .IP \fB\-statusmsg\fR 4 .IX Item "-statusmsg" The argument is the message to be shown on the status bar when the mouse pauses over this client. If this is not specified, but \&\fB\-msg\fR is specified then the message displayed on the status bar is the same as the argument for \fB\-msg\fR. If you give it a scalar reference then it is dereferenced before being displayed. Useful if the postcommand is used to change the message. .IP \fB\-balloonmsg\fR 4 .IX Item "-balloonmsg" The argument is the message to be displayed in the balloon that will be popped up when the mouse pauses over this client. As with \&\fB\-statusmsg\fR if this is not specified, then it takes its value from the \fB\-msg\fR specification if any. If neither \fB\-balloonmsg\fR nor \fB\-msg\fR are specified, or they are the empty string then no balloon is popped up instead of an empty balloon. If you give it a scalar reference then it is dereferenced before being displayed. Useful if the postcommand is used to change the message. .IP \fB\-msg\fR 4 .IX Item "-msg" The catch-all for \fB\-statusmsg\fR and \fB\-balloonmsg\fR. This is a convenient way of specifying the same message to be displayed in both the balloon and the status bar for the client. .IP \fB\-initwait\fR 4 .IX Item "-initwait" .PD 0 .IP \fB\-state\fR 4 .IX Item "-state" .IP \fB\-statusbar\fR 4 .IX Item "-statusbar" .IP \fB\-balloonposition\fR 4 .IX Item "-balloonposition" .IP \fB\-postcommand\fR 4 .IX Item "-postcommand" .IP \fB\-cancelcommand\fR 4 .IX Item "-cancelcommand" .IP \fB\-motioncommand\fR 4 .IX Item "-motioncommand" .PD These options allow you to override the balloon's default value for those option for some of the widgets it is attached to. It accepts the same values as above and will default to the \fBBalloon\fR's value. .SS \fBdetach(\fP\fIwidget\fP\fB)\fP .IX Subsection "detach(widget)" Detaches the specified \fIwidget\fR from the help system. .SS \fBdestroy\fP .IX Subsection "destroy" Destroys the specified balloon. .SH "ADVERTISED SUBWIDGETS" .IX Header "ADVERTISED SUBWIDGETS" The balloon label is advertised as \f(CW\*(C`message\*(C'\fR. .SH EXAMPLES .IX Header "EXAMPLES" See the balloon demo included with the widget demo script that came with the distribution for examples on various ways to use balloons. .SH NOTES .IX Header "NOTES" Because of the overhead associated with each balloon you create (from tracking the mouse movement to know when to activate and deactivate them) you will see the best performance (low CPU consumption) if you create as few balloons as possible and attach them to as many widgets as you can. In other words, don't create a balloon for each widget you want to attach one to. .SH CAVEATS .IX Header "CAVEATS" Pressing any button will deactivate (cancel) the current balloon, if one exists. You can usually make the balloon reappear by moving the mouse a little. Creative use of the 3 command options can help you out also. If the mouse is over the balloon when a menu is unposted then the balloon will remain until you move off of it. .SH BUGS .IX Header "BUGS" If using balloons attached to listbox entries or canvas items in a scrolled widget, then the subwidget have to be used: .PP .Vb 1 \& $balloon\->attach($w\->Subwidget("scrolled"), \-msg => ...); .Ve .SH AUTHORS .IX Header "AUTHORS" \&\fBRajappa Iyer\fR did the original coding. .PP \&\fBJason A. Smith\fR added support for menus and made some other enhancements. .PP \&\fBSlaven Rezic\fR added support for canvas items. .PP \&\fBGerhard Petrowitsch\fR added intelligent positioning .PP \&\fBJack Dunnigan\fR Made positioning \fImore\fR intelligent and added support for multiple monitors under single logical screen. .SH HISTORY .IX Header "HISTORY" The code and documentation was derived from Balloon.tcl from the Tix4.0 distribution by Ioi Lam and modified by the above mentioned authors. This code may be redistributed under the same terms as Perl.