From 7ed44d94d47a381a6a14405da5a274133d8a2100 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Mon, 11 Nov 2019 19:36:00 +0100 Subject: [PATCH] Improve keyboard arrow keys navigation. --- Classes/DocumentWindowController.swift | 16 ++++ .../PropertyView/Base.lproj/ChapterView.xib | 47 +++++----- Classes/PropertyView/Base.lproj/MovieView.xib | 61 ++++++------- Classes/PropertyView/Base.lproj/SoundView.xib | 25 +++--- Classes/PropertyView/Base.lproj/VideoView.xib | 85 ++++++++++--------- .../PropertyView/ChapterViewController.swift | 2 +- .../PropertyView/EmptyViewController.swift | 2 +- .../PropertyView/MovieViewController.swift | 2 +- .../MultiSelectViewController.swift | 2 +- Classes/PropertyView/PropertyView.swift | 20 +++++ .../PropertyView/SoundViewController.swift | 2 +- .../PropertyView/VideoViewController.swift | 2 +- Subler.xcodeproj/project.pbxproj | 4 + 13 files changed, 158 insertions(+), 112 deletions(-) create mode 100644 Classes/PropertyView/PropertyView.swift diff --git a/Classes/DocumentWindowController.swift b/Classes/DocumentWindowController.swift index 7f25726..7659d8a 100644 --- a/Classes/DocumentWindowController.swift +++ b/Classes/DocumentWindowController.swift @@ -563,4 +563,20 @@ final class DocumentWindowController: NSWindowController, TracksViewControllerDe return true } + // MARK: Keyboard navigation + + override func keyDown(with event: NSEvent) { + guard let key = event.charactersIgnoringModifiers?.utf16.first else { super.keyDown(with: event); return } + + if key == NSRightArrowFunctionKey || key == NSLeftArrowFunctionKey { + let detailsItem = splitViewController.splitViewItems[1] + if let propertyView = detailsItem.viewController.children.first as? PropertyView { + propertyView.navigate(direction: Int(key)) + } + } else { + super.keyDown(with: event) + } + } + + } diff --git a/Classes/PropertyView/Base.lproj/ChapterView.xib b/Classes/PropertyView/Base.lproj/ChapterView.xib index 9b3fc32..2de3577 100755 --- a/Classes/PropertyView/Base.lproj/ChapterView.xib +++ b/Classes/PropertyView/Base.lproj/ChapterView.xib @@ -1,14 +1,15 @@ - + - + - + + @@ -19,25 +20,25 @@ - + - + - + - + - + - + @@ -45,12 +46,12 @@ - + - + @@ -307,11 +308,11 @@ - + - + @@ -328,12 +329,12 @@ - + - + @@ -343,11 +344,11 @@ - + - + @@ -371,11 +372,11 @@ - - - - + - +