Select items by clicking the card instead of copying them
Copying was a side effect of a click, which made it impossible to build a selection with the mouse and surprising when the intent was to pick something up rather than copy it immediately. A click now selects (or deselects), and copying is an explicit action from the selection bar or the right-click menu.
This commit is contained in:
@@ -242,7 +242,7 @@ struct PanelView: View {
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { handleClick(item) }
|
||||
.help("Click to copy · checkbox to tick off · Cmd+click to select several · Shift+click for a range · right-click for more")
|
||||
.help("Click to select · Shift+click for a range · right-click to copy, delete and more")
|
||||
.contextMenu { contextMenu(for: item) }
|
||||
}
|
||||
|
||||
@@ -561,6 +561,12 @@ struct PanelView: View {
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
Spacer()
|
||||
if selection.count == 1, let id = selection.first, let item = store.item(id) {
|
||||
Button("Copy") { copy(item) }
|
||||
.font(.caption)
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(Color.accentColor)
|
||||
}
|
||||
Button("Copy as List") { copySelection(asList: true) }
|
||||
.font(.caption)
|
||||
.buttonStyle(.plain)
|
||||
@@ -669,17 +675,16 @@ struct PanelView: View {
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
/// A click anywhere on the card selects it (Shift+click selects a range).
|
||||
/// Copying is then an action on the selection — from the selection bar or
|
||||
/// the right-click menu — rather than the side effect of a click.
|
||||
private func handleClick(_ item: PromptItem) {
|
||||
let modifiers = NSApp.currentEvent?.modifierFlags ?? []
|
||||
if modifiers.contains(.command) {
|
||||
toggleSelection(item.id)
|
||||
return
|
||||
}
|
||||
if modifiers.contains(.shift), let anchor = lastSelectedID, anchor != item.id {
|
||||
selectRange(from: anchor, to: item.id)
|
||||
return
|
||||
}
|
||||
copy(item)
|
||||
toggleSelection(item.id)
|
||||
}
|
||||
|
||||
private func toggleSelection(_ id: UUID) {
|
||||
|
||||
Reference in New Issue
Block a user