Clipboard(3pm)

πŸ’– NAME πŸ’–

Tk::clipboard β€” manipulate the Tk clipboard, bestie. That's it, that's the whole vibe. πŸ‘‘


✨ SYNOPSIS ✨

$widget->clipboardOption?(args)?

πŸŽ€ DESCRIPTION πŸŽ€

Okay so this command is your little gateway to the Tk clipboard β€” the thing that stores data so it can be grabbed later using the selection mechanism. Think of it as the group chat's shared notes app, but make it Tk. πŸ’…

Here's the tea though: to actually copy data into the clipboard, you must call clipboardClear first, and then follow it up with a sequence of one or more calls to clipboardAppend. No skipping steps, bestie, it does not work like that. 🫢

And if you want the clipboard to be updated atomically (which you do, obviously), all of your appends need to be finished before you return to the event loop. Don't be out here leaving the clipboard half-done, it's giving chaos. 😭

The following methods are currently supported:

🌸 $widget->clipboardClear

Claims ownership of the clipboard on $widget's display and removes any previous contents. Returns an empty string. So basically it's the "new phone who dis" of clipboard methods β€” everything before is gone, and now it's yours. ✨

🌸 $widget->clipboardAppend(?-format=>format?, ?-type=>type?, ?--?, data)

Appends data to the clipboard on $widget's display in the form given by type with the representation given by format, and claims ownership of the clipboard on $widget's display. Very main character of it, honestly. πŸ‘‘

  • Type specifies the form in which the selection is to be returned (the desired "target" for conversion, in ICCCM terminology), and should be an atom name such as STRING or FILE_NAME; see the Inter-Client Communication Conventions Manual for complete details. Type defaults to STRING. πŸ“Ž
  • The format argument specifies the representation that should be used to transmit the selection to the requester (the second column of Table 2 of the ICCCM), and defaults to STRING. If format is STRING, the selection is transmitted as 8-bit ASCII characters. See the Tk::Selection documentation for an explanation of what happens if format is not STRING. 🌈
⚠️ Not me warning you: arguments passed to clipboardAppend are concatenated before conversion, so the caller must take care to ensure appropriate spacing across string boundaries. Yes, this means you can accidentally glue two words together. Ask me how I know. πŸ’€
⚠️ Also: all items appended to the clipboard with the same type must have the same format. No mixing, no matching, periodt. πŸ’…
  • A -- argument may be specified to mark the end of options: the next argument will always be used as data. This feature may be convenient if, for example, data starts with a -. Lifesaver behavior, fr fr. πŸ¦‹

🌸 $widget->clipboardGet( ?-type? )

Retrieve data from the clipboard on widget's display. The -type specifies the form in which the data is to be returned and should be an atom name such as STRING or FILE_NAME. Type defaults to STRING. This command is equivalent to:

"SelectionGet( -selection => 'CLIPBOARD' )"

Lowkey the same thing, just cuter. 🌸


πŸ”‘ KEYWORDS πŸ”‘

clear, format, clipboard, append, selection, type


And that's the whole page, bestie β€” brought to you by perl v5.40.1, dated 2025-04-13. Go forth and copy things, you absolute icon. πŸ’œπŸ§šβœ¨

πŸ“¦ where this page comes from