Hello there,
Is there anyway to trap all keyboard events across my application? I need to know if user is entering anything using keyboard across my application (Application has multiple views). I was able to capture touchEvents by subclassing UIWindow but unable to capture keyboard events.
From stackoverflow
-
Not a simple answer, but I think you have two approaches available.
subclass the input components (UITextView, UITextField, etc) as you've done with the UIWindow.
Create a application wide UITextViewDelegate (and UITextFieldDelegate) and assign all your input field delegates to it.
iamiPhone : This is little tricky now and involves lots of work. I was hoping to see some App level event to capture -
Use NSNotificationCenter
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyPressed:) name: UITextFieldTextDidChangeNotification object: nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyPressed:) name: UITextViewTextDidChangeNotification object: nil]; ........ -(void) keyPressed: (NSNotification*) notification { NSLog([[notification object]text]); }
0 comments:
Post a Comment