Debian Codegraph @

pod/Balloon.pod

raw
1
2 =head1 NAME
3
4 Tk::Balloon - pop up help balloons.
5
6 =for pm Tixish/Balloon.pm
7
8 =for category Tix Extensions
9
10 =head1 SYNOPSIS
11
12 use Tk::Balloon;
13 ...
14 $b = $top->Balloon(-statusbar => $status_bar_widget);
15
16 # Normal Balloon:
17 $b->attach($widget,
18 -balloonmsg => "Balloon help message",
19 -statusmsg => "Status bar message");
20
21 # Balloon attached to entries in a menu widget:
22 $b->attach($menu, -state => 'status',
23 -msg => ['first menu entry',
24 'second menu entry',
25 ...
26 ],
27 );
28
29 # Balloon attached to individual items in a canvas widget:
30 $b->attach($canvas, -balloonposition => 'mouse',
31 -msg => {'item1' => 'msg1',
32 'tag2' => 'msg2',
33 ...
34 },
35 );
36
37 # Balloon attached to items in a listbox widget:
38 $b->attach($listbox, -balloonposition => 'mouse',
39 -msg => ['first listbox element',
40 '2nd listbox element',
41 ...
42 ],
43 );
44
45 =head1 DESCRIPTION
46
47 B<Balloon> provides the framework to create and attach help
48 balloons to various widgets so that when the mouse pauses over the
49 widget for more than a specified amount of time, a help balloon is
50 popped up.
51
52 =head2 Balloons and Menus or Listboxes
53
54 If the balloon is attached to a B<Menu> or B<Listbox> widget and the
55 message arguments are array references, then each element in the array
56 will be the message corresponding to a menu entry or listbox element.
57 The balloon message will then be shown for the entry which the mouse
58 pauses over. Otherwise it is assumed that the balloon is to be
59 attached to the B<Menu> or B<Listbox> as a whole. You can have
60 separate status and balloon messages just like normal balloons.
61
62 =head2 Balloons and Canvases
63
64 If the balloon is attached to a B<Canvas> widget and the message
65 arguments are hash references, then each hash key should correspond to
66 a canvas item ID or tag and the associated value will correspond to the
67 message for that canvas item. The balloon message will then be shown for
68 the current item (the one at the position of the mouse). Otherwise it is
69 assumed that the balloon is to be attached to the B<Canvas> as a whole.
70 You can have separate status and balloon messages just like normal
71 balloons.
72
73 =head2 Balloons and HLists
74
75 If the balloon is attached to a B<HList> widget and the message
76 arguments are hash references, then each hash key should correspond to
77 a HList path and the associated value will correspond to the message
78 for that HList item. The balloon message will then be shown for the
79 current item (the one at the position of the mouse). Otherwise it is
80 assumed that the balloon is to be attached to the B<HList> as a whole.
81 You can have separate status and balloon messages just like normal
82 balloons.
83
84 =head2 Balloon Position
85
86 By default, the balloon pops up at the lower right side of the client.
87 If it would extend outside the lower screen border, it's positioned at the
88 upper right side. If it would extend outside the right screen border
89 it's shown on the lower left side of the client. If it would extend
90 outside both the lower and the right screen border, it's positioned
91 at the upper left side of the client. Thus, the little arrow always
92 points to the attached client.
93
94 =head1 OPTIONS
95
96 B<Balloon> accepts all of the options that the B<Frame> widget
97 accepts. In addition, the following options are also recognized.
98
99 =over 4
100
101 =item B<-initwait>
102
103 Specifies the amount of time to wait without activity before
104 popping up a help balloon. Specified in milliseconds. Defaults to
105 350 milliseconds. This applies to both the popped up balloon and
106 the status bar message.
107
108 =item B<-state>
109
110 Can be one of B<'balloon'>, B<'status'>, B<'both'> or B<'none'>
111 indicating that the help balloon, status bar help, both or none
112 respectively should be activated when the mouse pauses over the
113 client widget. Default is B<'both'>.
114
115 =item B<-statusbar>
116
117 Specifies the widget used to display the status message. This
118 widget should accept the B<-text> option and is typically a
119 B<Label>. If the widget accepts the B<-textvariable> option and
120 that option is defined then it is used instead of the B<-text>
121 option.
122
123 =item B<-balloonposition>
124
125 Can be one of B<'widget'> or B<'mouse'>. It controls where the balloon
126 will popup. B<'widget'> makes the balloon appear at the lower right
127 corner of the widget it is attached to (default), and B<'mouse'> makes
128 the balloon appear below and to the right of the current mouse position.
129
130 =item B<-postcommand>
131
132 This option takes a B<CODE> reference which will be executed before the
133 balloon and statusbar messages are displayed and should return a true
134 or false value to indicate whether you want the balloon to be displayed
135 or not. This also lets you control where the balloon is positioned by
136 returning a true value that looks like I<X,Y> (matches this regular
137 expression: C</^(\d+),(\d+)$/>). If the postcommand returns a value that
138 matches that re then those coordinates will be used as the position to
139 post the balloon. I<Warning:> this subroutine should return quickly or
140 the balloon response will appear slow.
141
142 =item B<-cancelcommand>
143
144 This option takes a B<CODE> reference which will be executed before the
145 balloon and statusbar messages are canceled and should return a true
146 or false value to indicate whether you want the balloon to be canceled
147 or not. I<Warning:> this subroutine should return quickly or the balloon
148 response will appear slow.
149
150 =item B<-motioncommand>
151
152 This option takes a B<CODE> reference which will be executed for any
153 motion event and should return a true or false value to indicate
154 whether the currently displayed balloon should be canceled (deactivated).
155 If it returns true then the balloon will definitely be canceled, if it
156 returns false then it may still be canceled depending the internal rules.
157 I<Note:> a new balloon may be posted after the B<-initwait> time
158 interval, use the B<-postcommand> option to control that behavior.
159 I<Warning:> the subroutine should be extremely fast or the balloon
160 response will appear slow and consume a lot of CPU time (it is executed
161 every time the mouse moves over the widgets the balloon is attached to).
162
163 =item B<-numscreens>
164
165 This option accepts an integer 1 or greater. This option should be used
166 to avoid disjointed balloons across multiple screens in single logical
167 sceen (SLS) mode. This only currently works in the horizontal direction.
168 Example: If you are running dual screens in SLS mode then you would set
169 this value to 2. Default value is 1.
170
171 =back
172
173 =head1 METHODS
174
175 The B<Balloon> widget supports only three non-standard methods:
176
177 =head2 B<attach(>I<widget>, I<options>B<)>
178
179 Attaches the widget indicated by I<widget> to the help system. The
180 allowed options are:
181
182 =over 4
183
184 =item B<-statusmsg>
185
186 The argument is the message to be shown on the status bar when the
187 mouse pauses over this client. If this is not specified, but
188 B<-msg> is specified then the message displayed on the status bar
189 is the same as the argument for B<-msg>. If you give it a scalar
190 reference then it is dereferenced before being displayed. Useful
191 if the postcommand is used to change the message.
192
193 =item B<-balloonmsg>
194
195 The argument is the message to be displayed in the balloon that
196 will be popped up when the mouse pauses over this client. As with
197 B<-statusmsg> if this is not specified, then it takes its value
198 from the B<-msg> specification if any. If neither B<-balloonmsg>
199 nor B<-msg> are specified, or they are the empty string then
200 no balloon is popped up instead of an empty balloon. If you
201 give it a scalar reference then it is dereferenced before being
202 displayed. Useful if the postcommand is used to change the message.
203
204 =item B<-msg>
205
206 The catch-all for B<-statusmsg> and B<-balloonmsg>. This is a
207 convenient way of specifying the same message to be displayed in
208 both the balloon and the status bar for the client.
209
210 =item B<-initwait>
211
212 =item B<-state>
213
214 =item B<-statusbar>
215
216 =item B<-balloonposition>
217
218 =item B<-postcommand>
219
220 =item B<-cancelcommand>
221
222 =item B<-motioncommand>
223
224 These options allow you to override the balloon's default value for
225 those option for some of the widgets it is attached to. It accepts the
226 same values as above and will default to the B<Balloon>'s value.
227
228 =back
229
230 =head2 B<detach(>I<widget>B<)>
231
232 Detaches the specified I<widget> from the help system.
233
234 =head2 B<destroy>
235
236 Destroys the specified balloon.
237
238 =head1 ADVERTISED SUBWIDGETS
239
240 The balloon label is advertised as C<message>.
241
242 =head1 EXAMPLES
243
244 See the balloon demo included with the widget demo script that came with
245 the distribution for examples on various ways to use balloons.
246
247 =head1 NOTES
248
249 Because of the overhead associated with each balloon you create (from
250 tracking the mouse movement to know when to activate and deactivate
251 them) you will see the best performance (low CPU consumption) if you
252 create as few balloons as possible and attach them to as many widgets
253 as you can. In other words, don't create a balloon for each widget
254 you want to attach one to.
255
256 =head1 CAVEATS
257
258 Pressing any button will deactivate (cancel) the current balloon,
259 if one exists. You can usually make the balloon reappear by moving
260 the mouse a little. Creative use of the 3 command options can help
261 you out also. If the mouse is over the balloon when a menu is unposted
262 then the balloon will remain until you move off of it.
263
264 =head1 BUGS
265
266 If using balloons attached to listbox entries or canvas items in a
267 scrolled widget, then the subwidget have to be used:
268
269 $balloon->attach($w->Subwidget("scrolled"), -msg => ...);
270
271 =head1 AUTHORS
272
273 B<Rajappa Iyer> <[email protected]> did the original coding.
274
275 B<Jason A. Smith> <[email protected]> added support for menus and made some
276 other enhancements.
277
278 B<Slaven Rezic> <[email protected]> added support for canvas items.
279
280 B<Gerhard Petrowitsch> <[email protected]> added intelligent positioning
281
282 B<Jack Dunnigan> <[email protected]> Made positioning I<more> intelligent and
283 added support for multiple monitors under single logical screen.
284
285 =head1 HISTORY
286
287 The code and documentation was derived from Balloon.tcl from the
288 Tix4.0 distribution by Ioi Lam and modified by the above mentioned
289 authors. This code may be redistributed under the same terms as Perl.
290
291 =cut
292
293