gui without Interface Builder
gui without Interface Builder
- Subject: gui without Interface Builder
- From: email@hidden
- Date: Sun, 10 Jul 2005 02:07:53 -0700
Hi all,
The following code pops up a window with an NSTextView, but the view
won't take keyboard focus/input, so I can't edit the text. Can
anyone tell me what's wrong? According to the printfs, the textview
become the firstResponder, and is editable.
thanks,
Rob
#include <stdio.h>
#include <Cocoa/Cocoa.h>
id main_window;
id text_view;
id make_window()
{
NSRect rect = NSMakeRect(20,20,300,300);
unsigned style = NSTitledWindowMask |
NSClosableWindowMask |
NSResizableWindowMask;
id win = [[NSWindow alloc] initWithContentRect: rect
styleMask: style
backing: NSBackingStoreBuffered
defer: YES];
[win setTitle: @"Test"];
return win;
}
id make_text_view(NSRect contentBounds)
{
id tv = [[NSTextView alloc]
initWithFrame:contentBounds];
return tv;
}
int main()
{
id pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
id win = main_window = make_window();
id text = make_text_view([[win contentView] bounds]);
[text setString: @"dude..."];
[win setContentView: text];
[win makeKeyAndOrderFront: nil];
printf("makeFirst: %i\n", [win makeFirstResponder: text]);
printf("is editable: %i\n", [text isEditable]);
printf("is selectable: %i\n", [text isSelectable]);
[NSApp run];
[pool release];
return 0;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden