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 05-22-2008, 03:46 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2008
Location: Colorado
Posts: 313
Send a message via AIM to jonc
Default Supress keyboard on text field touch

When a text field is tapped I would like to have my own code present a picker and not have the keyboard come up at all. This seems really easy but I can't seem to figure it out. Has anyone else done this?
jonc is offline   Reply With Quote
Old 05-22-2008, 06:48 PM   #2 (permalink)
New Member
 
Join Date: Apr 2008
Location: Lexington, KY
Posts: 108
Default Re: Supress keyboard on text field touch

Suppress editing of the field with
[textField setEditable:NO];

and then in the touch handler see if the touch was within textField's frame


(I have not tried this so YMMV)
Fastrak is offline   Reply With Quote
Old 05-22-2008, 07:27 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2008
Location: Colorado
Posts: 313
Send a message via AIM to jonc
Default Re: Supress keyboard on text field touch

Well I ended up disabling user interaction and disabling the text fields. They just sit there now and don't interact with any touches but I can change the content in the code. I thought about determining if the touches were in the frame but it seemed like a lot of effort. I was using IB for this view so I added invisible buttons over the text fields that would pick up touches.

Interesting thing is that when the alpha is less than 0.02 the buttons didn't pickup the "touch up inside" action. I didn't think this was normal behavior, specially for it to stop working at 0 and 0.1, it just didn't make any sense.

I ended up putting the button behind the disabled text field and it picks up the touches. If anyone does figure out how to suppress the keyboard and still pick up touch events from a text field I would love to know.
jonc is offline   Reply With Quote
Old 05-22-2008, 09:13 PM   #4 (permalink)
New Member
 
Join Date: Apr 2008
Location: Lexington, KY
Posts: 108
Default Re: Supress keyboard on text field touch

Quote:
I thought about determining if the touches were in the frame but it seemed like a lot of effort.
Its actually pretty straightforward.


Code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch;
	touch=[touches anyObject];
	CGPoint point=[touch locationInView:self];
	
	if (CGRectContainsPoint([myTextBox frame],point))
	{
	    //press was on me!	
	    [self doSomething];
	}
	
  }
Fastrak is offline   Reply With Quote
Old 05-22-2008, 09:20 PM   #5 (permalink)
Registered Member
 
Join Date: Apr 2008
Location: Colorado
Posts: 313
Send a message via AIM to jonc
Default Re: Supress keyboard on text field touch

Thanks, that was actually probably a lot easier than what I did.

I hadn't used touchesBegan before and I assumed it would be a lot more difficult. So in theory if I threw that in the view controller and put my text box name it would work or would I have to do something else?
jonc is offline   Reply With Quote
Old 05-22-2008, 10:09 PM   #6 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 802
Default Re: Supress keyboard on text field touch

You have to do this with your custom UIIView, not the controller. The views are the object that display and respond directly to users.
scottiphone is offline   Reply With Quote
Old 05-26-2009, 08:44 PM   #7 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 41
Default

Quote:
Originally Posted by Fastrak View Post
Suppress editing of the field with
[textField setEditable:NO];

and then in the touch handler see if the touch was within textField's frame


(I have not tried this so YMMV)
When you do this, you no longer have a flashing cursor. Is there a way to do this so that one just looses the keyboard but doesn't loose the cursor and the clear button. That way you could place the cursor within the text and not just at the end and thereby insert or delete characters.

I've tried implementing a UITextFieldDelegate and sending [textField resignFirstResponder] but that doesn't work.

- Dan.
danbaumbach 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
UITextView keyboard Fastrak iPhone SDK Development 17 12-26-2009 06:10 PM
Keyboard hides text field - how do I fix this? pendraggon87 iPhone SDK Development 10 07-03-2008 08:43 AM
UIWebView keyboard Fastrak iPhone SDK Development 1 06-19-2008 05:21 PM
Adding button and text field in uitableviewcell sasikantpradeep iPhone SDK Development 1 06-06-2008 08:55 AM
Drop keyboard down with touch somewhere else? BuschyBoy iPhone SDK Development 2 04-21-2008 06:08 PM


» Advertisements
» Online Users: 240
17 members and 223 guests
ADY, AragornSG, BrianSlick, Dani77, Dattee, dre, glenn_sayers, HemiMG, JasonR, karlam963, nobre84, prchn4christ, Rudy, spiderguy84, themathminister, viniciusdamone, vvenkatachallam
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,884
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, karlam963
Powered by vBadvanced CMPS v3.1.0

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