first-responder

UITextField losing firstResponder after view appears

只愿长相守 提交于 2021-02-07 12:19:55
问题 I have a UIPageViewController . One page has a single button, and the other page has a UITextField with a button. When the page scrolls to the view with the field, I'd like it to becomeFirstResponder and open the keyboard. Here's what happens: I call [self.locationQuery becomeFirstResponder] ViewController's viewDidAppear method. But it never opens the keyboard. I do the same in viewWillAppear , and it appears briefly, but then is quickly dismissed. If I'm on the page with the text field, and

First responder on mouse down behavior NSControl and NSView

巧了我就是萌 提交于 2021-01-28 13:57:08
问题 I have a custom control. If it inherits from NSView , it automatically becomes the first responder when I click on it. If it inherits from NSControl , it does not. This difference in behavior persists, even if I override mouseDown(with:) and don't call super. Code: class MyControl: NSView { override var canBecomeKeyView: Bool { return true } override var acceptsFirstResponder: Bool { return true } override func drawFocusRingMask() { bounds.fill() } override var focusRingMaskBounds: NSRect {

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 close window (NSWindowController) by hitting the ESC key?

拟墨画扇 提交于 2020-02-23 08:01:39
问题 Issue I would like the user being able to close a window by hitting the ESC key but I can't get it to work in this specific case, hitting ESC triggers an error sound (the "no you can't do that" macOS bloop) and nothing happens. Context I'm making a subclass of NSWindowController which itself creates an instance of a subclass of NSViewController and sets it in a view. Both controllers have their own xib file. NSWindowController: final class MyWindowController: NSWindowController,

Slide UIInputView with UIViewController like Slack

旧巷老猫 提交于 2020-01-07 03:07:28
问题 I'd like to use the UIViewController's input accessory view like this: override func canBecomeFirstResponder() -> Bool { return true } override var inputAccessoryView: UIView! { return self.bar } but the issue is that I have a drawer like view and when I slide the view open, the input view stays on the window. How can I keep the input view on the center view like Slack does it. Where my input view stays at the bottom, taking up the full screen (the red is the input view in the image below):

What is a formal definition of a first responder in iOS?

…衆ロ難τιáo~ 提交于 2019-12-31 10:35:29
问题 I understand that a first responder object is the receives a callback signal according to input activity, etc and that it will bubble it up the chain until a responder willing to handle it can be found. But more formally, what is the scope of the first responder? For instance, is it an application-wide responder? It seems like being a first responder is simply saying that this particular object will receive notification of interaction. Can another responder steal the first responder status?

Custom inputView for UITextField , how do I direct input back to the text field?

旧街凉风 提交于 2019-12-29 22:06:17
问题 I have set a custom inputView to my UITextField . I need a way to display the data selected in my custom inputView in the UITextfield . I would like to achieve this the same way the system keyboard does it. Does anyone know how this is done? How does the system keyboard get a reference to the UITextfield that is the first responder? 回答1: How does the system keyboard get a reference to the UITextfield that is the first responder? It just asks the system for the first responder; unfortunately,

UIScrollview with two images - Keeping 1 image zoomable and 1 image static (fixed size)

会有一股神秘感。 提交于 2019-12-24 09:36:57
问题 I have a UIView which contains a zoomable UIImageView and also another semitransparent UIView on top of that. What I am trying to achieve is to be able to zoom the UIImageView while keeping the semitransparent view static and not zoomed. If I add the semitransparent UIView on top of the UIImageView (which is added to the UIScrollView ), everything zooms. However, if I add both as subviews to the base UIView , the touches only get tracked is the semitransparent UIView since its the last one

Setting the inputAccessoryView of a UITextField to its superview

岁酱吖の 提交于 2019-12-23 21:19:38
问题 I have a UITableView with an Add cell... row and would like to have a keyboard pop up with a view above it like in the "Messages" application, where the user can type the name of the new cell. I realize that there are several other ways to get user data, and several ways to implement the functionality that I am trying to achieve. For example, the iPod application presents a popup when a new playlist should be created. Right now, I have a hidden text field that is set to be the first responder

Determine if responder chain will handle an action

倖福魔咒の 提交于 2019-12-23 13:22:39
问题 The responder chain is cool. Particularly, being able to send custom actions to the first responder that will bubble up to anyone else that might be interested: [[UIApplication sharedApplication] sendAction: @selector(commandToSend) to: nil from: self forEvent: nil] . Or less custom actions with: [[UIApplication sharedApplication] sendAction: @selector(resignFirstResponder) to: nil from: self forEvent: nil] I'd like to know – is there a way to test before hand if a particular action from a