Skip to content

Commit

Permalink
Resolve keyboard navigation conflicts with date picker (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanzhong authored Mar 8, 2024
1 parent 2bc23f1 commit 68e5ddd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
17 changes: 17 additions & 0 deletions LunarBarMac/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,23 @@
}
}
},
"Enter Month" : {
"comment" : "[Menu] Enter a month using date picker",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "输入月份"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "輸入月份"
}
}
}
},
"Enter to select dates" : {
"comment" : "[AX] Tell the user to enter the current collection to select dates",
"localizations" : {
Expand Down
13 changes: 11 additions & 2 deletions LunarBarMac/Sources/Main/AppMainVC+Menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ private extension AppMainVC {

// Full-fledged picker that supports any year
menu.addItem({ [weak self] in
let item = NSMenuItem()
let picker = NSDatePicker()
picker.isBezeled = false
picker.isBordered = false
Expand All @@ -107,7 +106,17 @@ private extension AppMainVC {
picker.centerYAnchor.constraint(equalTo: wrapper.centerYAnchor),
])

item.view = wrapper
// Inside a submenu to avoid keyboard navigation conflicts
let menu = NSMenu()
menu.addItem({
let item = NSMenuItem()
item.view = wrapper

return item
}())

let item = NSMenuItem(title: Localized.UI.menuTitleEnterMonth)
item.submenu = menu
return item
}())

Expand Down
1 change: 1 addition & 0 deletions LunarBarMac/Sources/Shared/AppDefinitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum Localized {
// Menu
static let menuTitleGotoToday = String(localized: "Today", comment: "[Menu] Move to today")
static let menuTitleGotoMonth = String(localized: "Go to Month", comment: "[Menu] Select year and month")
static let menuTitleEnterMonth = String(localized: "Enter Month", comment: "[Menu] Enter a month using date picker")
static let menuTitleAppearance = String(localized: "Appearance", comment: "[Menu] Change dark mode preference")
static let menuTitleCalendarIcon = String(localized: "Calendar Icon", comment: "[Menu] Use a calendar icon as the menu bar icon")
static let menuTitleCurrentDate = String(localized: "Current Date", comment: "[Menu] Use the current date as the menu bar icon")
Expand Down

0 comments on commit 68e5ddd

Please sign in to comment.