nsdatepicker

NSDatePicker in NSStatusBar NSSMenuItem not receiving input

家住魔仙堡 提交于 2021-02-08 13:11:38
问题 A while back I wrote a simple calendar menu bar widget called Day-O. The calendar uses the stock NSDatePicker nested inside an NSView inside an NSMenuItem in an NSMenu added to an NSStatusItem. The app has an activationPolicy of .accessory (originally set via the plist's "Application is agent" bool). At some point (maybe with the El Capitan update?) the calendar stopped responding to input. When the app first launches you can click the status bar item to expand the menu and interact with the

NSDatePicker in NSStatusBar NSSMenuItem not receiving input

余生长醉 提交于 2021-02-08 13:10:54
问题 A while back I wrote a simple calendar menu bar widget called Day-O. The calendar uses the stock NSDatePicker nested inside an NSView inside an NSMenuItem in an NSMenu added to an NSStatusItem. The app has an activationPolicy of .accessory (originally set via the plist's "Application is agent" bool). At some point (maybe with the El Capitan update?) the calendar stopped responding to input. When the app first launches you can click the status bar item to expand the menu and interact with the

NSDatePicker in NSStatusBar NSSMenuItem not receiving input

ⅰ亾dé卋堺 提交于 2021-02-08 13:09:01
问题 A while back I wrote a simple calendar menu bar widget called Day-O. The calendar uses the stock NSDatePicker nested inside an NSView inside an NSMenuItem in an NSMenu added to an NSStatusItem. The app has an activationPolicy of .accessory (originally set via the plist's "Application is agent" bool). At some point (maybe with the El Capitan update?) the calendar stopped responding to input. When the app first launches you can click the status bar item to expand the menu and interact with the

NSDatePicker focus on day of the month editing

妖精的绣舞 提交于 2020-05-24 05:18:17
问题 I have a code similar to this: let datePicker = NSDatePicker(....) self.addSubview(datePicker) self.window?.makeFirstResponder(datePicker) When makeFirstResponder is called first element gets editing focus. For U.S region this picks day of the month, because date format is DD-MM-YYYY. For other regions when date format is YYYY-MM-DD, YYYY gets editing focus. How can I force NSDatePicker to start editing day of the month no matter what date format is? 回答1: You can use DateFormatter method func

How can the arrow keys be allowed to operate for graphical NSDatePicker?

て烟熏妆下的殇ゞ 提交于 2019-12-24 21:30:04
问题 This seems simple, but essential. Place an NSDatePicker (style: graphical) into a window, build & run, then attempt to use arrow keys to move around. The only response is a 'ding' from the computer. I've overridden -keydown in a simple custom NSDatePicker subclass and printed theEvent to notice they have corresponding keyCodes of 123 through 126. Then, I stumbled upon resetting the date picker's date after each arrow button press, inside -keydown , like so: - (void)keyDown:(NSEvent *)theEvent

empty NSDatePicker

大城市里の小女人 提交于 2019-12-23 15:50:07
问题 Hi Is it possible to have a NSDatePicker representing a nil object? Something like -/-/- or any other way. Thanks, Radu 回答1: Short answer: No NSDatePicker simply ignores invalid dates and nil. For example, this does not update the NSDatePicker, the old value remains: [datePicker setDateValue:nil]; Only solution: Detect nil and do something specific: if(date == nil) { // Set Specific Date NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"yyyyMMdd"];

NSDatePicker misbehaving with arrow keys

霸气de小男生 提交于 2019-12-12 18:27:15
问题 I have used NSDatePicker s (without steppers) in the cells of a column in an NSTableView . The date pickers are used to set a duration of time in hours, minutes and seconds. If I highlight one of the controls and use the arrow keys to set the values, the date picker displays some weird behaviour: Seconds increment by two for every time I press up arrow (whereas it should increment by one for each key press); Seconds do not decrement when I press down arrow; Every time I increment and

Add sound to play at time from NSDatePicker [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-12 06:59:54
问题 This question already has answers here : How to get audio to play at time from NSDatePicker? (2 answers) Closed 4 years ago . I'm creating a project which requires the user to be able to set a sound to play at a specific time and I'm currently doing that with local notification. I would like to change that to use AVAudioPlayer , and I was wondering, what would be the best approach? The objects I've got at the moment are a NSDatePicker and a stringFromDate string. My aim is to create an alarm

Action is called twice (mouse up/down) when Target is clicked in Cocoa/objective-c

心不动则不痛 提交于 2019-12-11 13:27:10
问题 I have a NSDatePicker (target), and datePickerAction (action) - (IBAction)datePickerAction:(id)sender { if( [[[NSApplication sharedApplication] currentEvent] modifierFlags] & NSShiftKeyMask ) NSLog(@"shift pressed %@", [datePicker dateValue]); else NSLog(@"hello %@", [datePicker dateValue]); } It works well as when I click a date in NSDatePicker object, the method(action) is called, the problem is that the method is called twice - mouse down/up. Can I make the method called only once (up or

NSDatePicker - getting the value when it is changed

懵懂的女人 提交于 2019-12-07 03:21:01
问题 How would I get notified of a value of a NSDatePicker, when it's changed? 回答1: I've only done it on the iPhone with UIDatePicker but it is similar on the Mac, you register as a delegate and receive messages. See Apple's Docs here. I should clarify, this tells you when it changed, you still need to call -dateValue to get the date. 回答2: The same you would any other control. Options are: Target/Action Binding Observe notification Delegate 回答3: You can bind the picker's value binding to a