Implement Copy/Paste Functionality #35

Open
opened 2026-03-27 23:18:06 +00:00 by thib8956 · 0 comments
Owner

Overview

Implement proper copy/paste functionality with clipboard support.

Current State

  • C key duplicates selection immediately (clone in place)
  • No separate copy/paste operations
  • No clipboard abstraction

Implementation Plan

1. Clipboard system

  • Create Clipboard class to hold copied shapes
  • Store clones (not references) to prevent modification
  • Support single and multi-shape copy

2. Copy operation (Ctrl+C)

  • Copy selected shapes to clipboard
  • Visual feedback: brief flash or outline effect
  • Do not modify model yet

3. Paste operation (Ctrl+V)

  • Clone shapes from clipboard
  • Offset position by (20, 20) to avoid exact overlap
  • Add to model at new position
  • Add to selection

4. Cut operation (Ctrl+X)

  • Copy to clipboard
  • Delete from model

5. Deep copy considerations

  • Clone shapes with their attributes
  • Preserve colors, selection state
  • Handle SCollection: deep clone all children

Files to modify

  • Modify: ui/Controller.java - add copy/paste handlers
  • Modify: App.java - add Edit menu items
  • Create: Clipboard.java (optional abstraction)

Edge cases

  • Paste multiple times: each paste should create new instances
  • Copy then delete original: paste should still work (already cloned)
  • Copy empty selection: show warning or ignore
  • Paste position: keep within canvas bounds
## Overview Implement proper copy/paste functionality with clipboard support. ## Current State - C key duplicates selection immediately (clone in place) - No separate copy/paste operations - No clipboard abstraction ## Implementation Plan ### 1. Clipboard system - Create Clipboard class to hold copied shapes - Store clones (not references) to prevent modification - Support single and multi-shape copy ### 2. Copy operation (Ctrl+C) - Copy selected shapes to clipboard - Visual feedback: brief flash or outline effect - Do not modify model yet ### 3. Paste operation (Ctrl+V) - Clone shapes from clipboard - Offset position by (20, 20) to avoid exact overlap - Add to model at new position - Add to selection ### 4. Cut operation (Ctrl+X) - Copy to clipboard - Delete from model ### 5. Deep copy considerations - Clone shapes with their attributes - Preserve colors, selection state - Handle SCollection: deep clone all children ## Files to modify - Modify: ui/Controller.java - add copy/paste handlers - Modify: App.java - add Edit menu items - Create: Clipboard.java (optional abstraction) ## Edge cases - Paste multiple times: each paste should create new instances - Copy then delete original: paste should still work (already cloned) - Copy empty selection: show warning or ignore - Paste position: keep within canvas bounds
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: thib8956/new-shapes#35