PDA

View Full Version : Get text from TextField



SunnyMan
July 29th, 2009, 08:43 PM
Hi all, i need your help, i have simple project(cocoa app)

http://img269.imageshack.us/img269/7328/picture1drd.png

untitled.h:


#import <Cocoa/Cocoa.h>

@interface untitled : NSObject {
IBOutlet id mylabel;
}
- (IBAction)ButtonClick:(id)sender;
@end


untitled.m:


#import "untitled.h"

@implementation untitled

- (IBAction)ButtonClick:(id)sender {

[mylabel setStringValue:@"Test"];
}
@end


How I can get string value, from TextField. I click to the button([mylabel setStringValue:@"Test"]) and i need get value(my own value, not this static string "Test") from TextField and put in the Label(where "Test" right now)

Thx a lot.

heibert
July 31st, 2009, 04:48 PM
If your new to Cocoa/C++ you might want to go a different route.
For example BASIC. In FutureBASIC you write your code and can use Carbon NIB windows. In REALbasic you design the interface and click on a button and put a little bit of code in the button to make it do something. FutureBASIC converts the BASIC code to Objective C; REALbasic compiles Universal Binary and soon will add Cocoa Support.

heibert
July 31st, 2009, 04:49 PM
If your new to Cocoa/C++ you might want to go a different route.
For example BASIC. In FutureBASIC you write your code and can use Carbon NIB windows. In REALbasic you design the interface and click on a button and put a little bit of code in the button to make it do something. FutureBASIC converts the BASIC code to Objective C; REALbasic compiles Universal Binary and soon will add Cocoa Support.

heibert
July 31st, 2009, 04:50 PM
For FutureBASIC go to http://4toc.com/fb/index.htm
For REALbasic go to http://www.realsoftware.com

Mikuro
August 3rd, 2009, 02:13 PM
Since you already know how to set up outlets and actions, this should be simple.

First, set up a new outlet (let's call it "myfield"), and connect it to the text field. Then just do something like this:
[mylabel setStringValue:[myfield stringValue]];

SunnyMan
August 5th, 2009, 07:26 AM
Thx guys for your help, I already done. Thx