Tryst::UI::CanvasItem
A handle onto one or more canvas items, addressed by Tk's own
tagOrId - either the numeric id a create call returns (a single
item) or an arbitrary tag string (every item currently carrying
it, zero or more). Every method here is exactly that uniform -
Tk's own canvas command already treats a tag and an id identically
for move/coords/itemconfigure/delete/stacking/scale, so a shared
tag is addressable as a group with no separate "group handle" type:
get one via a shape-creation method (see Handle#line and friends, a
single-item handle) or Handle#tagged (an existing tag, whatever it
currently matches).
Not ported: #on_drag/#draggable - Handle's own on_drag is still deferred too (see handle.cr's own doc comment), and neither is exercised anywhere in this port's own scope (goldberg_engine.rb only ever uses #on_click/#on_right_click on a CanvasItem, and Handle#on_click/#on_right_click directly on the canvas itself for whole-canvas clicks). Add both back alongside Handle's own on_drag, together, if a future port genuinely needs them.
Constructors
Instance methods
Set a single item option - item[:fill] = "red". Shorthand for configure(opt => value) when there's only one to change.
Bring to the front of the stacking order (drawn last, on top of everything), or - given above - just in front of that one item/tag instead of all the way to the front.
Whether any item currently matches #tag_or_id - always true for a single-item handle from a creation method (the item exists until #delete'd), meaningful for a Handle#tagged group that may currently match zero items.
Move relative to the current position.
Fires on a left click, only when the click lands on this specific item/tag - other items on the same canvas are untouched. Wired immediately, via the canvas's own bind subcommand (Tk has no per-item widget path to bind a plain bind against) - unlike Handle, a CanvasItem only ever exists post-realize, so there's no queue-before-realize phase to worry about here.
Fires on a right click, however the platform spells it (see MouseEvents::RIGHT_CLICK_EVENTS). Handle it yourself with a block, or use the overload below to pop up a menu instead.
Replace the coordinate list outright (as opposed to #move's relative shift). Flat or nested (e.g. [[x1, y1], [x2, y2]]) - flattened either way, same as a shape-creation method's own coords.
Scale coordinates relative to a fixed point (ox, oy origin; sx, sy scale factors).
Send to the back of the stacking order (drawn first, under everything), or - given below - just behind that one item/tag instead of all the way to the back.
Tk's own name for #bring_to_front.
The canvas's own path, marked past the point a real Tk path
stops applying - an item/tag has no independent Tk path of its
own, only the canvas does. ! is illegal in a Tk path segment,
so handing this to a raw Tk command fails loudly (an "invalid
command name" Tcl error) instead of silently misbehaving - the
same marked-address shape MenuEntryAddressing#virtual_path uses
for a menu entry, the other kind of thing with no Tk path of its
own.