[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to make a window visible ?
From: |
Pete French |
Subject: |
How to make a window visible ? |
Date: |
Sun, 13 Jan 2002 18:29:17 +0000 |
Under other OpenStep implementations sending the method "makeKeyAndOrderFront"
to a window makes it visible. This does not appear to happen under GNUstep,
how do I actually get a window to appear on the screen ? I have
included the very short code I am using below - I insrted the 'puts()' calls
dependent on the return from 'isVisible' so that I can see at what point the
window becomes visible. Under OS42 it does so when ordered front, under GNUstep
it is never made visisble. i assume I have missed some obvious step somewhere,
thanks for any help !
-bat.
------------------------------------------------------------------
NSWindow *theWindow = nil;
NSView *theView = nil;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSApp = [[NSApplication sharedApplication] retain];
/* create a window */
theWindow = [[NSWindow alloc]
initWithContentRect:(NSRect){ {100,100}, {150,150} }
styleMask:NSTitledWindowMask
backing:NSBackingStoreRetained
defer:NO];
[theWindow setTitle:@"My Test Window"];
[theWindow setReleasedWhenClosed:YES];
puts("Made the window");
if([theWindow isVisible])
puts("Window is visible");
else
puts("Window is not visible");
/* create the view and initialise it */
theView = [[NSView alloc] initWithFrame:
[[theWindow contentView] frame]];
[theView allocateGState];
[theWindow setContentView:theView];
puts("Made the view");
if([theWindow isVisible])
puts("Window is visible");
else
puts("Window is not visible");
/* send it to the front */
[theWindow makeKeyAndOrderFront:nil];
puts("Sent to the front");
if([theWindow isVisible])
puts("Window is visible");
else
puts("Window is not visible");
/* make the view as dirty and redisplay the window */
[[theWindow contentView] setNeedsDisplay:YES];
[theWindow displayIfNeeded];
if([theWindow isVisible])
puts("Window is visible");
else
puts("Window is not visible");
/* flush and sleep */
PSWait();
sleep(5);
/* close it */
[theWindow close];
[pool release];
return 0;
- How to make a window visible ?,
Pete French <=