nsresponder

NSApplication responder chain for arrow keys

℡╲_俬逩灬. 提交于 2020-05-24 05:33:08
问题 I have an NSTextField in my window and 4 menu items with key equivalents ← ↑ → ↓ . When the text field is selected and I press an arrow key, I would expect the cursor to move in the text field but instead the corresponding menu item action is performed. So there has to be an issue in the responder chain. To figure out what's wrong I've watched WWDC 2010 Session 145 – Key Event Handling in Cocoa Applications mentioned in this NSMenuItem KeyEquivalent space " " bug thread. The event flow for

How to deal with first responder and a NSPopover

爷,独闯天下 提交于 2020-01-31 08:57:50
问题 I’m trying to replicate the behaviour of the search field in iTunes, for looking up stock symbols and names. Specifically, as you start typing in the search field a popover appears with the filtered items. For the most part I have this working however what I can’t replicate is the way it handles first responder I have my popover appear after three characters are entered. At this point the NSSearchField would lose first responder status and therefore I could no longer continue typing. The

How to deal with first responder and a NSPopover

淺唱寂寞╮ 提交于 2020-01-31 08:56:12
问题 I’m trying to replicate the behaviour of the search field in iTunes, for looking up stock symbols and names. Specifically, as you start typing in the search field a popover appears with the filtered items. For the most part I have this working however what I can’t replicate is the way it handles first responder I have my popover appear after three characters are entered. At this point the NSSearchField would lose first responder status and therefore I could no longer continue typing. The

Forwarding drag & drop event to parent view

ε祈祈猫儿з 提交于 2020-01-13 19:01:32
问题 I have an application where I have one custom view which is derived from NSView. Within this view, there are several custom subviews, which are also derived from NSView. I want to implement a drag and drop behavior which allows URLs to be dropped onto the views. Everything is already working for the main view. So, actually I would have to implement dragging behavior handlers on the child-views and the parent-view class. The thing is, that I don't want to copy the complete handling code to all

How to make an NSControl (e.g., NSTokenField) ignore mouse events

℡╲_俬逩灬. 提交于 2020-01-06 03:49:25
问题 Specifically, I'd like to make an NSTokenField ignore mouse events because I'm using it in a NSTableCellView just to display data in a tokenized way without allowing any editing. Setting the token field's enabled = NO works, except that it greys out the tokens and makes it hard to read the text. Setting the token field's editable = NO is pretty close to what I want—it prevents editing while preserving the token field's look—except that when I mouse over the tokens, they light up. If I could

UIScrollView prevents touchesBegan, touchesMoved, touchesEnded on view controller

随声附和 提交于 2019-12-28 05:31:47
问题 I am handling touches for a couple of my UI components in my view controller (custom subclass of UIViewController). It has methods touchesBegan:withEvent: , touchesMoved:withEvent: , and touchesEnded:withEvent: . It was working fine. Then I added a scroll view (UIScrollView) as the top view in the hierarchy. Now my touch handlers on the view controller don't work. They don't get called. The interesting thing is, I have various other UI components within the scroll view that do work. Some are

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

How to intercept keystrokes from within the field editor of an NSTextField?

大憨熊 提交于 2019-12-22 08:25:18
问题 Intro When my custom NSTextField is in "text editing mode" and the field editor has been placed in front of it as firstResponder I no longer get the keystrokes through NSTextField.keyDown(...) . I understand that the keystrokes are now being routed through the field editor . Most online recommendations are to override the following method within the delegate of the custom NSTextField : control(_:textView:doCommandBySelector:) I have indeed overridden this method but it doesn't seem to get

NSToolbarItem validation in relevant controller

折月煮酒 提交于 2019-12-22 05:42:07
问题 I have an NSToolbarItem with an NSButton as its view and an NSMenuItem in the main menu. Both have the same action, which is sent to the first responder, not to a particular target. That method is ultimately implemented in a subclass of NSSplitViewController, somewhere in the view hierarchy of the window’s content view. I want to validate both items, but have that specific split-view controller take care of the validation, because it relies on some conditions local to that controller. I

Cocoa: Forward actions (copy:, paste: etc.) up to the responder chain

时光总嘲笑我的痴心妄想 提交于 2019-12-12 16:26:46
问题 I have a subclass of NSOutlineView that implements copy: , paste: , cut: etc. Also, the NSDocument subclass implements these same methods. When the outline view is in the responder chain (is first responder or a parent view of it), all copy/paste events are intercepted by the NSOutlineView subclass. What I want, is depending on the context catch some of these messages, or let them propagate and be caught by the NSDocument subclass. What I want is basically: - (void)copy:(id)sender { // If