• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: gui without Interface Builder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gui without Interface Builder


  • Subject: Re: gui without Interface Builder
  • From: Matt Neuburg <email@hidden>
  • Date: Mon, 11 Jul 2005 11:31:24 -0700

On Sun, 10 Jul 2005 02:07:53 -0700, email@hidden said:
>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.

Just as a data point, I pasted your code directly into the main.m of a fresh
Cocoa project and it works fine (until you make the mistake of resizing the
window, of course). m.


>#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;
>}
>
>
>
>

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>



 _______________________________________________
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

  • Follow-Ups:
    • Re: gui without Interface Builder
      • From: email@hidden
  • Prev by Date: Re: Inserting Special Characters into a String
  • Next by Date: Re: Why does this leak memory?
  • Previous by thread: gui without Interface Builder
  • Next by thread: Re: gui without Interface Builder
  • Index(es):
    • Date
    • Thread