Changeset 595 for trunk/Cocoa/Pester


Ignore:
Timestamp:
12/21/09 22:11:47 (15 years ago)
Author:
Nicholas Riley
Message:

Keyboard-accessible and better-behaving volume slider.

Location:
trunk/Cocoa/Pester/Source
Files:
4 added
3 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source/PSVolumeController.m

    r584 r595  
    1010#import "NJRSoundManager.h"
    1111#import "NJRNonCenteringWindow.h"
     12#include <Carbon/Carbon.h>
    1213
    1314@interface NSMenu (SnowLeopardAdditions)
     
    5657            }
    5758            [menu setAllowsContextMenuPlugIns: NO];
     59            // replace with http://waffle.wootest.net/2007/08/07/popping-up-a-menu-in-cocoa/
    5860            [menu popUpMenuPositioningItem: nil atLocation: point inView: view];
    5961            [menu release];
     
    100102- (IBAction)volumeSet:(NSSlider *)sender;
    101103{
     104    // XXX don't delay preview for keyboard adjustment
    102105    [delegate volumeController: self didSetVolume: [sender floatValue]];
    103     if (NSEventMaskFromType([[NSApp currentEvent] type]) & (NSLeftMouseUpMask | NSRightMouseUpMask | NSOtherMouseUpMask))
     106    NSLog(@"%@", [NSApp currentEvent]);
     107    unsigned eventMask = NSEventMaskFromType([[NSApp currentEvent] type]);
     108    // The event may simply be a mouse-up: close the menu.
     109    if (eventMask & (NSLeftMouseUpMask | NSRightMouseDownMask | NSOtherMouseDownMask))
     110        [menu cancelTracking];
     111    // On a quick click, the event may be a mouse down but the mouse button is no longer down.
     112    if (!(eventMask & (NSLeftMouseDownMask | NSRightMouseDownMask | NSOtherMouseDownMask)))
     113        return;
     114    // 10.6+: use [NSEvent pressedMouseButtons] instead
     115    if (GetCurrentButtonState() == 0)
    104116        [menu cancelTracking];
    105117}
  • trunk/Cocoa/Pester/Source/Pester.xcodeproj/project.pbxproj

    r594 r595  
    88
    99/* Begin PBXBuildFile section */
     10                E12CBFD310CC310800159E88 /* NJRMenuSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = E12CBFD210CC310800159E88 /* NJRMenuSlider.m */; };
    1011                E15044670CFCDC7E00DE47E9 /* NJRValidatingField.m in Sources */ = {isa = PBXBuildFile; fileRef = E15044660CFCDC7E00DE47E9 /* NJRValidatingField.m */; };
    1112                E17562620CF8C50B00FC5057 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E17562610CF8C50B00FC5057 /* Sparkle.framework */; };
     
    185186                E127900C0442A92900050002 /* PSVolumeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSVolumeController.h; sourceTree = "<group>"; };
    186187                E127900D0442A92900050002 /* PSVolumeController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSVolumeController.m; sourceTree = "<group>"; };
     188                E12CBFD110CC310800159E88 /* NJRMenuSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJRMenuSlider.h; sourceTree = "<group>"; };
     189                E12CBFD210CC310800159E88 /* NJRMenuSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJRMenuSlider.m; sourceTree = "<group>"; };
    187190                E130B9AC03B7C59700000028 /* PSPowerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSPowerManager.h; sourceTree = "<group>"; };
    188191                E130B9AD03B7C59700000028 /* PSPowerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSPowerManager.m; sourceTree = "<group>"; };
     
    671674                                F5F240B6036A862101FE7503 /* NJRFSObjectSelector.h */,
    672675                                F5F240B5036A862101FE7503 /* NJRFSObjectSelector.m */,
     676                                E12CBFD110CC310800159E88 /* NJRMenuSlider.h */,
     677                                E12CBFD210CC310800159E88 /* NJRMenuSlider.m */,
    673678                                F5F240CD036A877301FE7503 /* NJRQTMediaPopUpButton.h */,
    674679                                F5F240CC036A877301FE7503 /* NJRQTMediaPopUpButton.m */,
     
    938943                                E1B121970CF62FD1004975AA /* NSMenuItem-NJRExtensions.m in Sources */,
    939944                                E15044670CFCDC7E00DE47E9 /* NJRValidatingField.m in Sources */,
     945                                E12CBFD310CC310800159E88 /* NJRMenuSlider.m in Sources */,
    940946                        );
    941947                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.