Change focus when the sidebar is shown or hidden. Issue #1004

This commit is contained in:
Maurice Parker 2020-03-14 14:36:18 -05:00
parent 229aada857
commit 118ce73c08
2 changed files with 9 additions and 3 deletions

View File

@ -384,7 +384,7 @@
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE"> <menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/> <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections> <connections>
<action selector="toggleSidebar:" target="Ady-hI-5gd" id="dOo-rp-1f6"/> <action selector="toggleTheSidebar:" target="Ady-hI-5gd" id="1hl-EZ-ao4"/>
</connections> </connections>
</menuItem> </menuItem>
<menuItem isSeparatorItem="YES" id="jKG-b2-ZWf"/> <menuItem isSeparatorItem="YES" id="jKG-b2-ZWf"/>

View File

@ -226,7 +226,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
return validateToggleReadArticles(item) return validateToggleReadArticles(item)
} }
if item.action == #selector(toggleSidebar(_:)) { if item.action == #selector(toggleTheSidebar(_:)) {
guard let splitViewItem = sidebarSplitViewItem else { guard let splitViewItem = sidebarSplitViewItem else {
return false return false
} }
@ -360,8 +360,14 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
nextUnread(sender) nextUnread(sender)
} }
@IBAction func toggleSidebar(_ sender: Any?) { @IBAction func toggleTheSidebar(_ sender: Any?) {
splitViewController!.toggleSidebar(sender) splitViewController!.toggleSidebar(sender)
guard let splitViewItem = sidebarSplitViewItem else { return }
if splitViewItem.isCollapsed {
currentTimelineViewController?.focus()
} else {
sidebarViewController?.focus()
}
} }
@IBAction func markAboveArticlesAsRead(_ sender: Any?) { @IBAction func markAboveArticlesAsRead(_ sender: Any?) {