• 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: How do I prevent initWithFrame (NSView) being called?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I prevent initWithFrame (NSView) being called?


  • Subject: Re: How do I prevent initWithFrame (NSView) being called?
  • From: Hisaoki Nishida <email@hidden>
  • Date: Sun, 23 Jun 2002 19:30:57 -0400

Thanks a lot! I'll look into the example for window taking over, it seems like a nice simple way.
But I'd have to alter my design a bit, so I'll try to make it work without that.

Like you suggested, I implemented an awakeFromNib method in my custom window class.
But the initWithFrame method would be called anyway, even if I go full-screen. And I think this might be why my full-screen is not working (nothing drawn, no errors, but draw routines are called, which contains opengl commands (makeCurrentContext is set)). Although I don't know exactly why.

Thanks again,

Yuki N.


On Sunday, June 23, 2002, at 05:32 PM, Aram Greenman wrote:


On Sunday, June 23, 2002, at 12:27 AM, Hisaoki Nishida wrote:

Hi,

I have a situation where I need to prevent a subclass of NSOpenGLView from being called initWithFrame.
This is to examine beforehand if a user wants a window or full-screen (by reading user prefs), and I want the initWithFrame method to be called only when the user wants a window. If the user wants full-screen, then I don't want to load the nib/create a window, just create a full-screen OpenGL context. So I want to take the roll of calling initWithFrame on my view only when I want to.

What about this:

- (void)awakeFromNib {

...

if (fullScreen) {
// create full screen context
} else {
// create window
}
}




Also, in a related matter, is it possible initialize my view(and window) using dynamic rect size from user prefs, and not the static value in the nib?

In IB, uncheck the window's "Display at launch", then in -awakeFromNib:


[window setFrame:rect display:YES]; // or NO, doesn't matter, will
[window makeKeyAndOrderFront:self];



It is also possible to make a window take over the screen with CoreGraphics. There is a good tutorial on this on cocoadevcentral. This is probably a better solution, that way you don't have to mess with choosing between a window/view or context at all, all you have to do is make the window full-screen or not full-screen (and set its frame).

- (void)awakeFromNib {

...

[window setFrame:rect display:YES];

if (fullScreen)
CGDisplayCapture(kCGDirectMainDisplay);

[window makeKeyAndOrderFront:self];
}

Don't forget to add error checking to this code. Also you will probably want to make your window borderless if it is full screen and set it up to accept key events. See the tutorial I mentioned for more info.

HTH

aram




// Hisaoki Nishida
// <email@hidden>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: How do I prevent initWithFrame (NSView) being called?
      • From: Aram Greenman <email@hidden>
  • Prev by Date: Re: Scroller position
  • Next by Date: CDSA - they really don't want anyone to use it this bad?!?
  • Previous by thread: How do I prevent initWithFrame (NSView) being called?
  • Next by thread: Re: How do I prevent initWithFrame (NSView) being called?
  • Index(es):
    • Date
    • Thread