discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tutorials enhancement proposal : First Steps in GNUstep GUI Programm


From: Patrick Cardona
Subject: Re: Tutorials enhancement proposal : First Steps in GNUstep GUI Programming (2) : NSWindow, NSButton
Date: Wed, 10 Jun 2020 12:51:23 +0200
User-agent: GNUMail (Version 1.3.0)

Hi Richard,

Thank You for this aknowledgment. I will keep it in my Templates Library. I don't own the source of the Tutorial document, so only Nicola could modify it.

When You say :
the initWithContentRect:... method may destroy the original window...

Does it mean sometimes it does, sometimes it does not ? How this behaviour is predictable ?
Well, I understand I must continue to read, try and learn...

Regards,

--
Bien cordialement,
Patrick CARDONA
On 2020-06-10 12:04:11 +0200 Richard Frith-Macdonald <richard@frithmacdonald.me.uk> wrote:



On 10 Jun 2020, at 10:42, Patrick Cardona via Discussion list for the GNUstep programming environment <discuss-gnustep@gnu.org> wrote:


(2) In the method 'createWindow' :

- (void) createWindow
{
...
myWindow = [NSWindow alloc];

  /* Don't make a assignment of 'myWindow' again...
  myWindow = */
  /* So I kept only the message... */
  [myWindow initWithContentRect: rect
                       styleMask: styleMask
                       backing: NSBackingStoreBuffered
                       defer: NO];

The correct code here is

myWindow = [NSWindow alloc];
myWindow = [myWindow initWithContentRect: rect
                      styleMask: styleMask
                      backing: NSBackingStoreBuffered
                      defer: NO];

You *must* have the second assignment, because the initWithContentRect:... method may destroy the original window and return a new one. maybe it would help for the tutorial to have a comment saying that.

If you find it aesthetically displeasing to have two assignments, you can write the code as

myWindow = [[NSWindow alloc] initWithContentRect: rect
                      styleMask: styleMask
                      backing: NSBackingStoreBuffered
                      defer: NO];





reply via email to

[Prev in Thread] Current Thread [Next in Thread]