- Timestamp:
- 09/20/09 04:54:14 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/PSVolumeController.m
r136 r583 22 22 if ( (self = [self initWithWindowNibName: @"Volume"]) != nil) { 23 23 [self window]; // connect outlets 24 NSWindow *window = [[NJRNonCenteringWindow alloc] initWithContentRect: [contentView bounds] styleMask: NSBorderlessWindowMask | NSTexturedBackgroundWindowMaskbacking: NSBackingStoreBuffered defer: NO];24 NSWindow *window = [[NJRNonCenteringWindow alloc] initWithContentRect: [contentView bounds] styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: NO]; 25 25 26 26 if ([NJRSoundManager volumeIsNotMutedOrInvalid: volume]) … … 30 30 31 31 [window setContentView: contentView]; 32 [window setInitialFirstResponder: volumeSlider]; 33 [window makeFirstResponder: volumeSlider]; 32 34 [window setOpaque: NO]; 33 35 [window setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.81f alpha: 0.9f]]; … … 51 53 // -[NSApplication beginModalSessionForWindow:] shows and centers the window; we use NJRNonCenteringWindow to prevent the repositioning from succeeding 52 54 NSModalSession session = [NSApp beginModalSessionForWindow: window]; 53 [volumeSlider mouseDown: [NSApp currentEvent]]; 54 [NSApp runModalSession: session]; 55 // In 10.6, we can no longer force the modal session to work by "seeding" the slider with a mouse-down event. 56 // Instead, we stop the modal session on a volume change. 57 while ([NSApp runModalSession: session] == NSRunContinuesResponse) { 58 // Any mouse click events that do not change the slider value should abort. 59 NSEvent *event = [NSApp currentEvent]; 60 unsigned int eventTypeMask = NSEventMaskFromType([event type]); 61 if (eventTypeMask & (NSLeftMouseDownMask | NSRightMouseDownMask | NSOtherMouseDownMask)) { 62 [NSApp preventWindowOrdering]; 63 [NSApp discardEventsMatchingMask: NSAnyEventMask beforeEvent: event]; 64 break; 65 } 66 if (eventTypeMask & (NSKeyDownMask | NSKeyUpMask)) { 67 unsigned short keyCode = [event keyCode]; 68 if (keyCode == 53 || keyCode == 36 || keyCode == 76) { // escape, return, enter 69 [NSApp discardEventsMatchingMask: NSAnyEventMask beforeEvent: event]; 70 break; 71 } 72 } 73 } 55 74 [NSApp endModalSession: session]; 56 75 [window close]; … … 70 89 { 71 90 [delegate volumeController: self didSetVolume: [sender floatValue]]; 91 [NSApp stopModal]; 72 92 } 73 93
Note:
See TracChangeset
for help on using the changeset viewer.