canvas::tag(n)

πŸ“¦ version 0.7, in alpine 3.24

πŸ’… canvas::tag(n) β€” the manual, but make it make sense

okay so this is the canvas::tag(n) page from the Variations on a canvas corner of the world, and honestly? it's a little gem. bestie, if you've ever fought with a canvas tag list, this is your moment. ✨


πŸŽ€ NAME πŸŽ€

canvas::tag β€” literally just easier management of the tags on canvas items or item groups. that's the whole vibe. no cap. 🫢


✨ SYNOPSIS ✨

package require Tcl  8.5

package require Tk  8.5

package require canvas::tag  ?0.1?

::canvas::tag append canvas tagOrId tag...

::canvas::tag prepend canvas tagOrId tag...

::canvas::tag append canvas tagOrId index tag...

::canvas::tag remove canvas tagOrId tag...

::canvas::tag match canvas tagOrId pattern

like yes, append shows up twice, that is NOT a typo, it's a different signature, keep reading, i promise it slays πŸ’–


🌸 DESCRIPTION 🌸

okay so this package hands you a little pile of utility commands so managing the tag lists attached to canvas items (or item groups) is, like, actually pleasant instead of giving you a headache πŸ¦‹

here's the tea on the existing canvas API: a tag list can only be set as a whole. so if you want to add or remove even one tag, you're doing this whole ✨production✨ where you read the current tag list, modify it, then write the changed list back. so much effort. so much main-character energy spent on bookkeeping πŸ’€

the commands in this package hide all of that complexity from you. you just say what you want, and it handles the rest. iconic behavior, honestly πŸ‘‘


⭐ API ⭐

  • ::canvas::tag append canvas tagOrId tag... β€” adds the tags tag... to the tag list for the items identified by tagOrId in the canvas widget. and where do they go? at the end of the list, obviously πŸ’… the result of the command is the empty string.
  • ::canvas::tag prepend canvas tagOrId tag... β€” same idea, adds the tags tag... to the tag list for the items identified by tagOrId in the canvas widget, except these get added at the beginning of the list because someone has to go first 🌈 the result of the command is the empty string.
  • ::canvas::tag append canvas tagOrId index tag... β€” yup, append again, but with extra spice πŸ’– this one adds the tags tag... to the tag list for the items identified by tagOrId in the canvas widget, and the new tags are inserted before the element at index.
    • index 0 refers to the beginning of the list.
    • index end refers to after the end of the list.

the result of the command is the empty string.

  • ::canvas::tag remove canvas tagOrId tag... β€” this one ✨removes✨ the named tags tag... from the tag list for the items identified by tagOrId in the canvas widget. the result of the command is the empty string.
  • ::canvas::tag match canvas tagOrId pattern β€” this one goes hunting πŸ”₯ it finds all tags for the items identified by tagOrId in the canvas widget which match the glob pattern. the result of the command is a list of the matching tags. which may be empty.
lowkey important: an empty result is a totally valid answer, not an error. don't be dramatic about it πŸ™ˆ

πŸ’€ BUGS, IDEAS, FEEDBACK πŸ’€

bestie. this document, and the package it describes, will undoubtedly contain bugs and other problems. that's just how software is. 😭

so please report such in the category canvas of the Tklib Trackers [http://core.tcl.tk/tklib/reportlist].

and please also report any ideas for enhancements you may have for either the package and/or the documentation. they want to hear it, fr fr 🫢


πŸ”₯ KEYWORDS πŸ”₯

append tag, canvas, insert tag, remove tag, tags


and that's the whole page, bestie β€” no crumbs left behind πŸ“

this cute little number is brought to you by tklib, version 0.1, and it covers the canvas::tag(n) manual page ✨ go forth and tag responsibly πŸ’œ

πŸ“¦ where this page comes from