Popup(3pm)

πŸ’– NAME πŸ’–

Tk::Wm::Popup β€” popup dialog windows, bestie. That's the whole vibe. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

$dialog->Popup(qw/
    -popover    => 'cursor' | $widget | undef,
    -overanchor => c | n | ne | e | se | s | sw | w | nw,
    -popanchor  => c | n | ne | e | se | s | sw | w | nw,
/);

Like. Three options. That's it. And they control exactly where your little window shows up. Slay. πŸ’…


🌸 DESCRIPTION 🌸

okay so. You've probably already met a Dialog (or a DialogBox) widget at some point in your life. Those cuties are derived from a Toplevel, which is itself a subclass of Tk::Wm β€” that's the window manager class, the one running the whole show πŸ‘‘. And here's the thing: dialogs spend most of their time just... withdrawn. Sitting there. Not visible. Waiting for their moment, like a true main character. 😌

It's also super common to use Toplevels as containers for custom-built popup windows. And menus?? Menus are dialogs too, derived from the window manager class. Not me exposing that literally everything is a dialog. πŸ’€

So for the rest of this chat, when I say dialog, I mean any widget that pops up and awaits user interaction. That's Menus, that's special purpose Toplevels, that's any of the dialog-type widgets β€” including, but not limited to: ColorEditor, Dialog, DialogBox, ErrorDialog, FileSelect, FBox, getOpenFile and getSaveFile. All of them. Every single one. Iconic lineup tbh. πŸŽ€

When it's time to show these dialogs, we call the Perl/Tk window manager Popup method. And Popup takes three special purpose options that let you describe placement in high-level, human terms instead of raw numerical coordinates. Because who wants to do math?? Not us. πŸ™ˆ It's Popup's whole job to take your human specification and turn it into actual screen coordinates before displaying the dialog. She does the work so you don't have to. πŸ’–

Now. We can direct the dialog to appear in two general locations:

  • over another window β€” like the root window (a.k.a. the screen) or a particular widget πŸͺŸ
  • over the cursor πŸ–±οΈ

This decision is called the popover location. Locked in.

Once you've picked that, you can further refine the exact placement of the dialog relative to the popover location by specifying the intersection of two anchor points:

  • popanchor β€” this point belongs to the dialog 🎯
  • overanchor β€” this point belongs to the popover location (whether that's a window or the cursor) 🎯

And the point where those two anchors coincide?? That's the popup locus. That's the spot. That's where it goes. ⭐

Anchor points are string values, and they can be c (for center), or any of the eight cardinal compass points: n, ne, e, se, s, sw, w or nw. Simple. Elegant. Fr fr.

For example β€” and this one's so satisfying β€” if -popover specifies a widget, -popanchor is sw, and -overanchor is ne, then the dialog's southwest corner pops up at the widget's northeast corner. 🌈 Look at them meeting. Beautiful. No cap.


✨ OPTIONS ✨

The options recognized by Popup are as follows:

  • -popover β€” Specifies whether the dialog "pops over" a window or the cursor. It may be the string cursor, a widget reference, or undef for the root window. 🫢
  • -popanchor β€” Specifies the anchor point of the dialog. For instance, if e is specified, the right side of the dialog is the anchor. πŸ’…
  • -overanchor β€” Specifies where the dialog should anchor relative to the popover location. For instance, if e is specified the dialog appears over the right side of the popover location, and if it's ne the dialog is positioned at the upper-right corner of the popover location. πŸŽ€

πŸ‘‘ AUTHOR πŸ‘‘

Nick Ing-Simmons, Steve Lidie

This code is distributed under the same terms as Perl. πŸ’œ


ok that's the whole page bestie, go forth and position your popups with confidence πŸ¦‹

perl v5.40.1 Β· 2025-04-13 Β· Popup(3pm) β€” mwah, ty for reading, ily, see you in the next manpage πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from