Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-21-2010, 12:05 PM   #1 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default UIKeyboard detection

I need to find a way to detect key presses when the Keyboard pops up, and possibly telling me which letter was pressed?

Will I have to make my own keyboard here or what?
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 03-21-2010, 12:12 PM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

It depends which control you're using. Some things like the UITextField have a delegate method for handling key presses.
harrytheshark is offline   Reply With Quote
Old 03-21-2010, 12:17 PM   #3 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Quote:
Originally Posted by harrytheshark View Post
It depends which control you're using. Some things like the UITextField have a delegate method for handling key presses.
I'm using UITextView.
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 03-21-2010, 12:21 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

In that case, you can use:
Code:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
Where "text" is the text or key that was just entered.
harrytheshark is offline   Reply With Quote
Old 03-21-2010, 12:23 PM   #5 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Ah cool, I came across that but it didn't seem to be what I was looking for.
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 03-21-2010, 12:24 PM   #6 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Also, how would I see if the delete key was pressed?
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 03-21-2010, 12:35 PM   #7 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

The string entered is nothing. You can only capture the backspace when there is text in the view, otherwise the delegate method isn't called.
harrytheshark is offline   Reply With Quote
Old 03-28-2010, 05:00 PM   #8 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

I tried it (just got around to it) and the method isn't being called. I've put UITextViewDelegate inbetween the <> in the .h and in the method ive put return YES; at the bottom, what else?
__________________
Will code for food

Last edited by ZunePod; 03-28-2010 at 05:02 PM.
ZunePod is offline   Reply With Quote
Old 03-28-2010, 06:09 PM   #9 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Works fine for me:
Code:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
	
	NSLog(@"%@",text);
	
	return YES;
}
harrytheshark is offline   Reply With Quote
Old 03-28-2010, 06:45 PM   #10 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 126
Default

Quote:
Originally Posted by ZunePod View Post
I tried it (just got around to it) and the method isn't being called. I've put UITextViewDelegate inbetween the <> in the .h and in the method ive put return YES; at the bottom, what else?
Did you set the delegate to self?

Code:
myTextView.delegate = self;
javaconvert is offline   Reply With Quote
Old 03-28-2010, 07:23 PM   #11 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Thanks for that guys. It's always the simple things.
__________________
Will code for food
ZunePod is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 257
20 members and 237 guests
ADY, Alsahir, beleg_1998, Dani77, e2applets, iph_s, JamesCahall, JasonR, mer10, Monstertaco, piesia, prchn4christ, Promo Dispenser, Robiwan, Rudy, smithdale87, timle8n1, Touchmint, twerner
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,756
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:21 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0