Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions TablePro/TableProApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,22 @@ struct PasteboardCommands: Commands {
hasTableSelection: actions?.hasTableSelection ?? false
)
switch action {
case .textCopy, .copyRows:
case .textCopy:
NSApp.sendAction(#selector(NSText.copy(_:)), to: nil, from: nil)
case .copyRows:
if !NSApp.sendAction(#selector(NSText.copy(_:)), to: nil, from: nil) {
actions?.copySelectedRows()
}
case .copyTableNames:
actions?.copyTableNames()
}
}
.optionalKeyboardShortcut(shortcut(for: .copy))

Button("Copy Rows") {
NSApp.sendAction(#selector(KeyHandlingTableView.copyRowsAsTSV(_:)), to: nil, from: nil)
if !NSApp.sendAction(#selector(KeyHandlingTableView.copyRowsAsTSV(_:)), to: nil, from: nil) {
actions?.copySelectedRows()
}
}
.optionalKeyboardShortcut(shortcut(for: .copyRowsExplicit))
.disabled(!(actions?.hasRowSelection ?? false))
Expand Down
3 changes: 2 additions & 1 deletion TablePro/Views/Main/Child/MainEditorContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ struct MainEditorContentView: View {
case .createTable:
CreateTableView(
connection: connection,
coordinator: coordinator
coordinator: coordinator,
selectionState: selectionState
)
case .erDiagram:
erDiagramContent(tab: tab)
Expand Down
10 changes: 9 additions & 1 deletion TablePro/Views/Structure/CreateTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct CreateTableView: View {

let connection: DatabaseConnection
var coordinator: MainContentCoordinator?
let selectionState: GridSelectionState

@State private var structureChangeManager: StructureChangeManager
@State private var wrappedChangeManager: AnyChangeManager
Expand All @@ -50,9 +51,14 @@ struct CreateTableView: View {
@State private var sortState = SortState()
@State private var columnLayout = ColumnLayoutState()

init(connection: DatabaseConnection, coordinator: MainContentCoordinator?) {
init(
connection: DatabaseConnection,
coordinator: MainContentCoordinator?,
selectionState: GridSelectionState
) {
self.connection = connection
self.coordinator = coordinator
self.selectionState = selectionState

let manager = StructureChangeManager()
_structureChangeManager = State(wrappedValue: manager)
Expand Down Expand Up @@ -80,6 +86,8 @@ struct CreateTableView: View {
structureChangeManager.addNewColumn()
}
}
.onDisappear { selectionState.indices = [] }
.onChange(of: selectedRows) { _, newRows in selectionState.indices = newRows }
.onChange(of: selectedTab) { updateGridDelegate() }
.alert(String(localized: "Create Table Failed"), isPresented: $showError) {
Button("OK") {}
Expand Down
Loading