Skip to content

Commit

Permalink
Fix double click, fix width not reseting
Browse files Browse the repository at this point in the history
  • Loading branch information
FastestMolasses committed Dec 23, 2024
1 parent 2dbf5e0 commit ad66b30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,24 @@ extension ItemBoxWindowController {
tableView.rowSizeStyle = .custom
tableView.rowHeight = 21
tableView.gridStyleMask = []
tableView.target = self
tableView.action = #selector(tableViewClicked(_:))
let column = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("ItemsCell"))
tableView.addTableColumn(column)
}

@objc private func tableViewClicked(_ sender: Any?) {
if NSApp.currentEvent?.clickCount == 2 {
let row = tableView.selectedRow
guard row >= 0, row < items.count else {
return
}
let selectedItem = items[row]
delegate?.applyCompletionItem(selectedItem)
self.close()
}
}

func configureScrollView() {
scrollView.documentView = tableView
scrollView.hasVerticalScroller = true
Expand Down Expand Up @@ -173,13 +187,13 @@ extension ItemBoxWindowController {
let newFrame = NSRect(
x: currentFrame.minX,
y: bottomY,
width: currentFrame.width,
width: ItemBoxWindowController.DEFAULT_SIZE.width,
height: newHeight
)
window.setFrame(newFrame, display: true)
} else {
// When window is below cursor, maintain the top position
window.setContentSize(NSSize(width: currentFrame.width, height: newHeight))
window.setContentSize(NSSize(width: ItemBoxWindowController.DEFAULT_SIZE.width, height: newHeight))
}

// Dont allow vertical resizing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,6 @@ public final class ItemBoxWindowController: NSWindowController {
)
}

@objc private func tableViewDoubleClick(_ sender: Any) {
guard tableView.clickedRow >= 0 else { return }
let selectedItem = items[tableView.clickedRow]
delegate?.applyCompletionItem(selectedItem)
self.close()
}

private func resetScrollPosition() {
guard let clipView = scrollView.contentView as? NSClipView else { return }

Expand Down

0 comments on commit ad66b30

Please sign in to comment.