first-responder

NSOpenGLView, NSWindow & NSResponder - makeFirstResponder not working

℡╲_俬逩灬. 提交于 2019-12-23 13:00:17
问题 In the code below I am Initialising a NSViewController [a NSResponder], with a NSWindow , a NSOpenGLView , presenting the view and attempting to set the NSViewController as the windows first responder. It is not working. I was expecting to be able to hit a breakpoint in the keyUp: and keyDown: methods also below, but nothing is happening. Am I missing something? -(void)initwithFrame:(CGRect)frame { window = [[MyNSWindow alloc] initWithContentRect:frame styleMask:NSClosableWindowMask |

iOS — is it possible to force a UILabel subclass object to become the first responder?

懵懂的女人 提交于 2019-12-23 09:33:37
问题 Is there any way to do this? I tried putting the following into the subclass: - (BOOL)canBecomeFirstResponder { return YES; } But when I sent the object a becomeFirstResponder message, it still didn't become the first responder. 回答1: Yes, it is possible. You should: Override becomeFirstResponder to return YES . Set userInteractionEnabled to YES . Add a UITapGestureRecognizer to handle taps. Call becomeFirstResponder from the tap handler. You can even override inputView to get a input control

UISearchBar and resignFirstResponder

落花浮王杯 提交于 2019-12-23 07:00:07
问题 I have a very basic UITableView with an attached UISearchBar, and here's the flow of what happens UITableView is empty, user taps UISearchBar, and brings up keyboard. Once the user taps the Search button - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { [searchBar resignFirstResponder]; //move the keyboard out of the way //Code.... } Works just fine, and moves the keyboard out of the way, and populates the UITableView. The problem is any subsequent search attempts. The same

programmatically handling a text field within a uiwebview

烈酒焚心 提交于 2019-12-23 04:52:26
问题 I have a webpage with a text field and a submit button. That webpage is loaded within a UIWebView. How would I programmatically press the submit button for that webpage? Alternatively, how would I programmatically make the text field within the webpage the first responder and display the soft keyboard? Just programmatically re-create the same behavior as if the user had touched the text field on the webpage. I would like to make the assumption that the source of the page is unknown. This is

Cocoa validate menu items in multiple windows

元气小坏坏 提交于 2019-12-23 02:43:25
问题 I have a menu item "foobar" that i need to enable on my main window (app delegate), but disable on all other windows. I'd like to know how to do that, because the first responder business is very confusing to me. Here's what i have now: "foobar" item is connected to first responder's "foobar:" custom action in MainMenu.xib there is a "foobar:" action in the main app delegate so the menu item is enabled and works now i load and "makeKeyAndOrderFront" another window i focus some control on that

How to make embedded view controller part of the responder chain?

ぃ、小莉子 提交于 2019-12-22 10:48:22
问题 I am developing a Mac app using storyboards. I have a window that presents an NSViewController as its contents, which contains a "container view controller" that embeds an NSSplitViewController . The expected behaviour is for the NSSplitViewController to be part of the responder chain, such that a menu item that triggers the toggleSidebar action on the first responder actually collapses the item of the NSSplitViewController that's marked as a sidebar. However, this simply does not happen and

iPhone first responders

坚强是说给别人听的谎言 提交于 2019-12-22 03:49:05
问题 I am confused about the iPhone responder chain. Specifically, in the iPhone event handling guide http://developer.apple.com/iPhone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html, we have the following: The first responder is the responder object in an application (usually a UIView object) that is designated to be the first recipient of events other than touch events. But UIView is a subclass of UIResponder. And the UIResponder class reference

Why does setting initialFirstResponder have no effect?

送分小仙女□ 提交于 2019-12-21 12:14:29
问题 I have a simple form (NSWindow) with 3 text fields. NSWindow's initialFirstResponder is 'pointing' to the first field ( NSTextField ). All three text fields are circularly linked to each other via nextKeyView . Problem that I have is that when I start the application from Xcode it'll focus on the text field that was last active (in focus) when the application closed. So for example, if I name text fields A, B and C and initialFirstResponder is set to A. Now if I start the application, focus

Cannot set searchBar as firstResponder

无人久伴 提交于 2019-12-17 09:09:04
问题 I have a searchBar I'm setting in a tableviewcontroller. i've referenced this similar question UISearchBar cannot become first responder after UITableView did re-appear but am still unable to set it as first responder. In .h file: @property (strong, nonatomic) UISearchController *searchController; @property (strong, nonatomic) IBOutlet UISearchBar *searchBar; In view didload: self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil]; self.searchController

What are File Owner and First Responder in iOS - Xcode?

牧云@^-^@ 提交于 2019-12-17 07:01:16
问题 What are File Owner and First Responder in iOS - Xcode? 回答1: The File Owner is an instantiated, runtime object that owns the contents of your nib and its outlets/actions when the nib is loaded. It can be an instance of any class you like - take a look at the identity tab of the tool palette. File Owner is the main link between your application code and the contents of the nib file. For example, consider you have a UIViewController subclass with an IBOutlet for a UILabel. In interface builder