Skip to content

Commit

Permalink
Merge branch 'weakfl-366-copy-item-label' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
timbms committed Oct 1, 2019
2 parents 98ca4d3 + 08e2c95 commit 39ef0c2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions openHAB/OpenHABViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,21 @@ extension OpenHABViewController: UITableViewDelegate, UITableViewDataSource {
}
}
}

@available(iOS 13.0, *)
func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
if let cell = tableView.cellForRow(at: indexPath) as? GenericUITableViewCell, cell.widget.type == "Text", let text = cell.widget?.labelValue ?? cell.widget?.labelText, !text.isEmpty {
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { _ in
let copy = UIAction(title: "Copy item label", image: UIImage(systemName: "square.and.arrow.up")) { _ in
UIPasteboard.general.string = text
}

return UIMenu(title: "", children: [copy])
}
}

return nil
}
}

extension OpenHABViewController: AuthenticationChallengeResponsable {
Expand Down

0 comments on commit 39ef0c2

Please sign in to comment.