• 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
non-retained Windows, NSWindowExposedEventType - with source code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

non-retained Windows, NSWindowExposedEventType - with source code


  • Subject: non-retained Windows, NSWindowExposedEventType - with source code
  • From: "Thomas Martin" <email@hidden>
  • Date: Sat, 21 Sep 2002 17:38:31 -0600

I would like to be able to intercept and process the
NSAppKitDefined NSEvents of the subtype NSWindowExposedEventType,
when the non-retained NSWindow of my application becomes exposed.

The following code illustrates the situation - InterfaceBuilder is not used:

//--------------------------------------------------------------------------
---------------

int main(int argc, const char *argv[])
{
NSAutoreleasePool * Pool = [[NSAutoreleasePool alloc] init];

[[MyApplication sharedApplication] setDelegate: NSApp]; // create an
instance of MyApplication,
which is derived from NSApplication
[NSApp run]; // will return, because "applicationDidFinishLaunching" will
stop NSApp
[NSApp loop]; // call proprietary event loop procedure
return 0;
}

//--------------------------------------------------------------------------
---------------

@implementation MyApplication // my subclass of NSApplication

- (void)applicationDidFinishLaunching:(NSNotification *)Notification
{
// create a non-retained window e.g. with a button as the window's
contentview

NSRect ContentsFrame = {{20, 20}, {200, 30}};
NSButton * MyButton = [[NSButton alloc] initWithFrame : ContentsFrame];
NSWindow * MyWindow = [NSWindow alloc];
if(MyWindow){
NSString * AquaTitle = [NSString stringWithCString : "Expose Event
Test"];
NSRect ContentsFrame = {{200, 300}, {500, 400}};

[MyWindow initWithContentRect : ContentsFrame
styleMask : NSTitledWindowMask
backing : NSBackingStoreNonretained
defer : NO];

[MyWindow setTitle : AquaTitle];
[AquaTitle release];

[MyButton setTitle : [NSString stringWithCString : "Button"]];
[MyWindow setContentView : MyButton];

[MyWindow setBackgroundColor : [NSColor blackColor]];

[MyWindow makeKeyAndOrderFront : self]; // put the window on the screen
and activate it
}
[[Notification object] stop : self]; // stop the main event loop
return; // return to main()
}

//--------------------------------------------------------------------------
---------------

- (void)loop
{
NSEvent * CocoaEvent = NULL;
while((CocoaEvent = [NSApp nextEventMatchingMask : NSAnyEventMask
untilDate : [NSDate
distantFuture]
inMode :
NSDefaultRunLoopMode
dequeue : YES])){

if ([CocoaEvent type] == NSAppKitDefined){
// how are data1 and data2 used by the different event subtypes e.g.
NSWindowExposedEventType?
int data1 = [CocoaEvent data1];
int data2 = [CocoaEvent data2];
if ([CocoaEvent subtype] == NSWindowExposedEventType){
fprintf(stderr, "\nNSWindowExposedEventType\n"); // this never happens
!!??
}
}
[self sendEvent : CocoaEvent];

}// loop forever
return;
}

@end


Any sugguestion is greatly appreciated!

Sincerely,

Thomas

PS: On a second note - I could not find any documentation on the
details of NSEvent's -(int)data1 and -(int)data2 functions. I
would like to find out, how the returned integer values need to
be interpreted according to the designated event types (i.e.
NSAppKitDefined, etc.)
_______________________________________________
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.

  • Prev by Date: Re: NSRecentDocumentRecords
  • Next by Date: FileWrappers Sample Code?
  • Previous by thread: Re: Sending a keystroke
  • Next by thread: FileWrappers Sample Code?
  • Index(es):
    • Date
    • Thread