├── .gitignore ├── .ss1.png ├── .ss2.png ├── .ss3.png ├── LOpenPanelAccessoryView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── AnarL.xcuserdatad │ └── xcschemes │ ├── LOpenPanelAccessoryView.xcscheme │ └── xcschememanagement.plist ├── LOpenPanelAccessoryView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── MainMenu.xib ├── Info.plist ├── LOpenPanelWithFilter.h ├── LOpenPanelWithFilter.m └── main.m └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.xcodeproj 2 | *.xcassets 3 | *.lproj 4 | Info.plist -------------------------------------------------------------------------------- /.ss1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kito0615/LOpenPanelAccessoryView/1b86f26eb0d67b5cbe67cf07a3ac31ffb5db47cd/.ss1.png -------------------------------------------------------------------------------- /.ss2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kito0615/LOpenPanelAccessoryView/1b86f26eb0d67b5cbe67cf07a3ac31ffb5db47cd/.ss2.png -------------------------------------------------------------------------------- /.ss3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kito0615/LOpenPanelAccessoryView/1b86f26eb0d67b5cbe67cf07a3ac31ffb5db47cd/.ss3.png -------------------------------------------------------------------------------- /LOpenPanelAccessoryView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 995A97191E6E947B0093022B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 995A97181E6E947B0093022B /* AppDelegate.m */; }; 11 | 995A971C1E6E947B0093022B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 995A971B1E6E947B0093022B /* main.m */; }; 12 | 995A971E1E6E947B0093022B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 995A971D1E6E947B0093022B /* Assets.xcassets */; }; 13 | 995A97211E6E947B0093022B /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 995A971F1E6E947B0093022B /* MainMenu.xib */; }; 14 | 995A972D1E6EA2090093022B /* LOpenPanelWithFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 995A972C1E6EA2090093022B /* LOpenPanelWithFilter.m */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 995A97141E6E947B0093022B /* LOpenPanelAccessoryView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LOpenPanelAccessoryView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 995A97171E6E947B0093022B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 20 | 995A97181E6E947B0093022B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 21 | 995A971B1E6E947B0093022B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 22 | 995A971D1E6E947B0093022B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 995A97201E6E947B0093022B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 24 | 995A97221E6E947B0093022B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 25 | 995A972B1E6EA2090093022B /* LOpenPanelWithFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOpenPanelWithFilter.h; sourceTree = ""; }; 26 | 995A972C1E6EA2090093022B /* LOpenPanelWithFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LOpenPanelWithFilter.m; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 995A97111E6E947B0093022B /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 995A970B1E6E947B0093022B = { 41 | isa = PBXGroup; 42 | children = ( 43 | 995A97161E6E947B0093022B /* LOpenPanelAccessoryView */, 44 | 995A97151E6E947B0093022B /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | 995A97151E6E947B0093022B /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 995A97141E6E947B0093022B /* LOpenPanelAccessoryView.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 995A97161E6E947B0093022B /* LOpenPanelAccessoryView */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 995A97171E6E947B0093022B /* AppDelegate.h */, 60 | 995A97181E6E947B0093022B /* AppDelegate.m */, 61 | 995A971D1E6E947B0093022B /* Assets.xcassets */, 62 | 995A971F1E6E947B0093022B /* MainMenu.xib */, 63 | 995A97221E6E947B0093022B /* Info.plist */, 64 | 995A971A1E6E947B0093022B /* Supporting Files */, 65 | 995A972B1E6EA2090093022B /* LOpenPanelWithFilter.h */, 66 | 995A972C1E6EA2090093022B /* LOpenPanelWithFilter.m */, 67 | ); 68 | path = LOpenPanelAccessoryView; 69 | sourceTree = ""; 70 | }; 71 | 995A971A1E6E947B0093022B /* Supporting Files */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 995A971B1E6E947B0093022B /* main.m */, 75 | ); 76 | name = "Supporting Files"; 77 | sourceTree = ""; 78 | }; 79 | /* End PBXGroup section */ 80 | 81 | /* Begin PBXNativeTarget section */ 82 | 995A97131E6E947B0093022B /* LOpenPanelAccessoryView */ = { 83 | isa = PBXNativeTarget; 84 | buildConfigurationList = 995A97251E6E947B0093022B /* Build configuration list for PBXNativeTarget "LOpenPanelAccessoryView" */; 85 | buildPhases = ( 86 | 995A97101E6E947B0093022B /* Sources */, 87 | 995A97111E6E947B0093022B /* Frameworks */, 88 | 995A97121E6E947B0093022B /* Resources */, 89 | ); 90 | buildRules = ( 91 | ); 92 | dependencies = ( 93 | ); 94 | name = LOpenPanelAccessoryView; 95 | productName = LOpenPanelAccessoryView; 96 | productReference = 995A97141E6E947B0093022B /* LOpenPanelAccessoryView.app */; 97 | productType = "com.apple.product-type.application"; 98 | }; 99 | /* End PBXNativeTarget section */ 100 | 101 | /* Begin PBXProject section */ 102 | 995A970C1E6E947B0093022B /* Project object */ = { 103 | isa = PBXProject; 104 | attributes = { 105 | LastUpgradeCheck = 0820; 106 | ORGANIZATIONNAME = Digiarty; 107 | TargetAttributes = { 108 | 995A97131E6E947B0093022B = { 109 | CreatedOnToolsVersion = 8.2.1; 110 | ProvisioningStyle = Automatic; 111 | }; 112 | }; 113 | }; 114 | buildConfigurationList = 995A970F1E6E947B0093022B /* Build configuration list for PBXProject "LOpenPanelAccessoryView" */; 115 | compatibilityVersion = "Xcode 3.2"; 116 | developmentRegion = English; 117 | hasScannedForEncodings = 0; 118 | knownRegions = ( 119 | en, 120 | Base, 121 | ); 122 | mainGroup = 995A970B1E6E947B0093022B; 123 | productRefGroup = 995A97151E6E947B0093022B /* Products */; 124 | projectDirPath = ""; 125 | projectRoot = ""; 126 | targets = ( 127 | 995A97131E6E947B0093022B /* LOpenPanelAccessoryView */, 128 | ); 129 | }; 130 | /* End PBXProject section */ 131 | 132 | /* Begin PBXResourcesBuildPhase section */ 133 | 995A97121E6E947B0093022B /* Resources */ = { 134 | isa = PBXResourcesBuildPhase; 135 | buildActionMask = 2147483647; 136 | files = ( 137 | 995A971E1E6E947B0093022B /* Assets.xcassets in Resources */, 138 | 995A97211E6E947B0093022B /* MainMenu.xib in Resources */, 139 | ); 140 | runOnlyForDeploymentPostprocessing = 0; 141 | }; 142 | /* End PBXResourcesBuildPhase section */ 143 | 144 | /* Begin PBXSourcesBuildPhase section */ 145 | 995A97101E6E947B0093022B /* Sources */ = { 146 | isa = PBXSourcesBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | 995A972D1E6EA2090093022B /* LOpenPanelWithFilter.m in Sources */, 150 | 995A971C1E6E947B0093022B /* main.m in Sources */, 151 | 995A97191E6E947B0093022B /* AppDelegate.m in Sources */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXSourcesBuildPhase section */ 156 | 157 | /* Begin PBXVariantGroup section */ 158 | 995A971F1E6E947B0093022B /* MainMenu.xib */ = { 159 | isa = PBXVariantGroup; 160 | children = ( 161 | 995A97201E6E947B0093022B /* Base */, 162 | ); 163 | name = MainMenu.xib; 164 | sourceTree = ""; 165 | }; 166 | /* End PBXVariantGroup section */ 167 | 168 | /* Begin XCBuildConfiguration section */ 169 | 995A97231E6E947B0093022B /* Debug */ = { 170 | isa = XCBuildConfiguration; 171 | buildSettings = { 172 | ALWAYS_SEARCH_USER_PATHS = NO; 173 | CLANG_ANALYZER_NONNULL = YES; 174 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 175 | CLANG_CXX_LIBRARY = "libc++"; 176 | CLANG_ENABLE_MODULES = YES; 177 | CLANG_ENABLE_OBJC_ARC = YES; 178 | CLANG_WARN_BOOL_CONVERSION = YES; 179 | CLANG_WARN_CONSTANT_CONVERSION = YES; 180 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 181 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 182 | CLANG_WARN_EMPTY_BODY = YES; 183 | CLANG_WARN_ENUM_CONVERSION = YES; 184 | CLANG_WARN_INFINITE_RECURSION = YES; 185 | CLANG_WARN_INT_CONVERSION = YES; 186 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 187 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 188 | CLANG_WARN_UNREACHABLE_CODE = YES; 189 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 190 | CODE_SIGN_IDENTITY = "-"; 191 | COPY_PHASE_STRIP = NO; 192 | DEBUG_INFORMATION_FORMAT = dwarf; 193 | ENABLE_STRICT_OBJC_MSGSEND = YES; 194 | ENABLE_TESTABILITY = YES; 195 | GCC_C_LANGUAGE_STANDARD = gnu99; 196 | GCC_DYNAMIC_NO_PIC = NO; 197 | GCC_NO_COMMON_BLOCKS = YES; 198 | GCC_OPTIMIZATION_LEVEL = 0; 199 | GCC_PREPROCESSOR_DEFINITIONS = ( 200 | "DEBUG=1", 201 | "$(inherited)", 202 | ); 203 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 204 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 205 | GCC_WARN_UNDECLARED_SELECTOR = YES; 206 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 207 | GCC_WARN_UNUSED_FUNCTION = YES; 208 | GCC_WARN_UNUSED_VARIABLE = YES; 209 | MACOSX_DEPLOYMENT_TARGET = 10.12; 210 | MTL_ENABLE_DEBUG_INFO = YES; 211 | ONLY_ACTIVE_ARCH = YES; 212 | SDKROOT = macosx; 213 | }; 214 | name = Debug; 215 | }; 216 | 995A97241E6E947B0093022B /* Release */ = { 217 | isa = XCBuildConfiguration; 218 | buildSettings = { 219 | ALWAYS_SEARCH_USER_PATHS = NO; 220 | CLANG_ANALYZER_NONNULL = YES; 221 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 222 | CLANG_CXX_LIBRARY = "libc++"; 223 | CLANG_ENABLE_MODULES = YES; 224 | CLANG_ENABLE_OBJC_ARC = YES; 225 | CLANG_WARN_BOOL_CONVERSION = YES; 226 | CLANG_WARN_CONSTANT_CONVERSION = YES; 227 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 228 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 229 | CLANG_WARN_EMPTY_BODY = YES; 230 | CLANG_WARN_ENUM_CONVERSION = YES; 231 | CLANG_WARN_INFINITE_RECURSION = YES; 232 | CLANG_WARN_INT_CONVERSION = YES; 233 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 234 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 235 | CLANG_WARN_UNREACHABLE_CODE = YES; 236 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 237 | CODE_SIGN_IDENTITY = "-"; 238 | COPY_PHASE_STRIP = NO; 239 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 240 | ENABLE_NS_ASSERTIONS = NO; 241 | ENABLE_STRICT_OBJC_MSGSEND = YES; 242 | GCC_C_LANGUAGE_STANDARD = gnu99; 243 | GCC_NO_COMMON_BLOCKS = YES; 244 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 245 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 246 | GCC_WARN_UNDECLARED_SELECTOR = YES; 247 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 248 | GCC_WARN_UNUSED_FUNCTION = YES; 249 | GCC_WARN_UNUSED_VARIABLE = YES; 250 | MACOSX_DEPLOYMENT_TARGET = 10.12; 251 | MTL_ENABLE_DEBUG_INFO = NO; 252 | SDKROOT = macosx; 253 | }; 254 | name = Release; 255 | }; 256 | 995A97261E6E947B0093022B /* Debug */ = { 257 | isa = XCBuildConfiguration; 258 | buildSettings = { 259 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 260 | COMBINE_HIDPI_IMAGES = YES; 261 | INFOPLIST_FILE = LOpenPanelAccessoryView/Info.plist; 262 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 263 | MACOSX_DEPLOYMENT_TARGET = 10.8; 264 | PRODUCT_BUNDLE_IDENTIFIER = com.Digiarty.LOpenPanelAccessoryView; 265 | PRODUCT_NAME = "$(TARGET_NAME)"; 266 | }; 267 | name = Debug; 268 | }; 269 | 995A97271E6E947B0093022B /* Release */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 273 | COMBINE_HIDPI_IMAGES = YES; 274 | INFOPLIST_FILE = LOpenPanelAccessoryView/Info.plist; 275 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 276 | MACOSX_DEPLOYMENT_TARGET = 10.8; 277 | PRODUCT_BUNDLE_IDENTIFIER = com.Digiarty.LOpenPanelAccessoryView; 278 | PRODUCT_NAME = "$(TARGET_NAME)"; 279 | }; 280 | name = Release; 281 | }; 282 | /* End XCBuildConfiguration section */ 283 | 284 | /* Begin XCConfigurationList section */ 285 | 995A970F1E6E947B0093022B /* Build configuration list for PBXProject "LOpenPanelAccessoryView" */ = { 286 | isa = XCConfigurationList; 287 | buildConfigurations = ( 288 | 995A97231E6E947B0093022B /* Debug */, 289 | 995A97241E6E947B0093022B /* Release */, 290 | ); 291 | defaultConfigurationIsVisible = 0; 292 | defaultConfigurationName = Release; 293 | }; 294 | 995A97251E6E947B0093022B /* Build configuration list for PBXNativeTarget "LOpenPanelAccessoryView" */ = { 295 | isa = XCConfigurationList; 296 | buildConfigurations = ( 297 | 995A97261E6E947B0093022B /* Debug */, 298 | 995A97271E6E947B0093022B /* Release */, 299 | ); 300 | defaultConfigurationIsVisible = 0; 301 | }; 302 | /* End XCConfigurationList section */ 303 | }; 304 | rootObject = 995A970C1E6E947B0093022B /* Project object */; 305 | } 306 | -------------------------------------------------------------------------------- /LOpenPanelAccessoryView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LOpenPanelAccessoryView.xcodeproj/xcuserdata/AnarL.xcuserdatad/xcschemes/LOpenPanelAccessoryView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /LOpenPanelAccessoryView.xcodeproj/xcuserdata/AnarL.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | LOpenPanelAccessoryView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 995A97131E6E947B0093022B 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /LOpenPanelAccessoryView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // LOpenPanelAccessoryView 4 | // 5 | // Created by AnarLong on 2017/3/7. 6 | // Copyright © 2017年 __CompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : NSObject 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /LOpenPanelAccessoryView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // LOpenPanelAccessoryView 4 | // 5 | // Created by AnarLong on 2017/3/7. 6 | // Copyright © 2017年 __CompanyName__. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "LOpenPanelWithFilter.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @property (weak) IBOutlet NSWindow *window; 15 | @end 16 | 17 | @implementation AppDelegate 18 | 19 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 20 | // Insert code here to initialize your application 21 | } 22 | 23 | 24 | - (void)applicationWillTerminate:(NSNotification *)aNotification { 25 | // Insert code here to tear down your application 26 | } 27 | 28 | - (IBAction)open:(id)sender { 29 | 30 | NSDictionary * option = @{kFilterSizeKey : NSStringFromRect(NSMakeRect(0, 0, 500, 22)), @"MP4 Files(*.mp4, *.mov)" : @[@"mp4", @"mov", @"avi"], @"All types.(*.*)" : @[]}; 31 | LOpenPanelWithFilter * op = [LOpenPanelWithFilter openPanelWithFilterOptions:option]; 32 | NSUInteger state = [op runModal]; 33 | 34 | if (state == NSOKButton) { 35 | NSLog(@"%@", [[[op URLs] firstObject] path]); 36 | } 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /LOpenPanelAccessoryView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /LOpenPanelAccessoryView/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | Default 540 | 541 | 542 | 543 | 544 | 545 | 546 | Left to Right 547 | 548 | 549 | 550 | 551 | 552 | 553 | Right to Left 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | Default 565 | 566 | 567 | 568 | 569 | 570 | 571 | Left to Right 572 | 573 | 574 | 575 | 576 | 577 | 578 | Right to Left 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | -------------------------------------------------------------------------------- /LOpenPanelAccessoryView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2017年 __CompanyName__. All rights reserved. 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /LOpenPanelAccessoryView/LOpenPanelWithFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // LOpenPanelWithFilter.h 3 | // LOpenPanelAccessoryView 4 | // 5 | // Created by AnarLong on 2017/3/7. 6 | // Copyright © 2017年 __CompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define kFilterSizeKey @"FilterSizeKey" 12 | 13 | @interface LOpenPanelWithFilter : NSOpenPanel 14 | 15 | /** 16 | OpenPanel with fitler options 17 | 18 | @param options Fitler options 19 | @Note 20 | 1. Option's key is will show for user to read. Values means the open type filters, the type of value is Array. 21 | 22 | 2. Options must have the kFilterSizeKey and proper value for the fitler(PopUpButton). Use NSStringFromRect() save NSRect 23 | 24 | 3. For example: 25 | 26 | kFitlerSizeKey : @"{{0, 0}, {200, 21}}" 27 | 28 | @"H.264 Files" : @[@"mp4", @"mov", @"mkv"] 29 | 30 | @return return LOpenPanelWithFilter instance. 31 | */ 32 | + (instancetype)openPanelWithFilterOptions:(NSDictionary *)options; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /LOpenPanelAccessoryView/LOpenPanelWithFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // LOpenPanelWithFilter.m 3 | // LOpenPanelAccessoryView 4 | // 5 | // Created by AnarLong on 2017/3/7. 6 | // Copyright © 2017年 __CompanyName__. All rights reserved. 7 | // 8 | 9 | #import "LOpenPanelWithFilter.h" 10 | 11 | @implementation LOpenPanelWithFilter 12 | { 13 | NSDictionary * _options; 14 | } 15 | 16 | static LOpenPanelWithFilter * instance = nil; 17 | 18 | + (instancetype)openPanelWithFilterOptions:(NSDictionary *)options 19 | { 20 | static dispatch_once_t onceToken; 21 | dispatch_once(&onceToken, ^{ 22 | instance = (LOpenPanelWithFilter *)[[super class] openPanel]; 23 | }); 24 | [instance setupFiltersWithOptions:options]; 25 | return instance; 26 | } 27 | 28 | - (void)setupFiltersWithOptions:(NSDictionary *)options 29 | { 30 | NSUInteger count = [[options allKeys] count]; 31 | 32 | if (count > 1) { 33 | _options = options; 34 | NSString * filterSizeValue = [options objectForKey:kFilterSizeKey]; 35 | NSRect filterRect = NSRectFromString(filterSizeValue); 36 | 37 | NSPopUpButton * pub = [[NSPopUpButton alloc] initWithFrame:filterRect]; 38 | 39 | [pub removeAllItems]; 40 | [pub setTarget:self]; 41 | [pub setAction:@selector(popUpButtonAction:)]; 42 | 43 | for (NSString * title in [_options allKeys]) { 44 | if ([title isEqualToString:kFilterSizeKey]) { 45 | continue; 46 | } 47 | [pub addItemWithTitle:title]; 48 | } 49 | 50 | [pub selectItemAtIndex:0]; 51 | [self popUpButtonAction:pub]; 52 | [self setAccessoryView:pub]; 53 | } 54 | } 55 | 56 | - (void)popUpButtonAction:(id)sender 57 | { 58 | NSString * titleKey = [sender titleOfSelectedItem]; 59 | NSArray * allowedTypes = [_options objectForKey:titleKey]; 60 | if ([allowedTypes count] < 1) { 61 | [self setAllowedFileTypes:nil]; 62 | } else { 63 | [self setAllowedFileTypes:allowedTypes]; 64 | } 65 | } 66 | 67 | - (void)dealloc 68 | { 69 | _options = nil; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /LOpenPanelAccessoryView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LOpenPanelAccessoryView 4 | // 5 | // Created by AnarLong on 2017/3/7. 6 | // Copyright © 2017年 Digiarty. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LOpenPanelAccessoryView 2 | 3 | [![star this repo](http://githubbadges.com/star.svg?user=Kito0615&repo=LOpenPanelAccessoryView&style=default&color=fff&background=3466ae)](https://github.com/Kito0615/LOpenPanelAccessoryView) [![fork this repo](http://githubbadges.com/fork.svg?user=Kito0615&repo=LOpenPanelAccessoryView&style=default&color=fff&background=3466ae)](https://github.com/Kito0615/LOpenPanelAccessoryView/fork) 4 | 5 | ***This open panel with filter. You can use this Panel set filter easily, when your app support too many types of files.*** 6 | 7 | **You can use this open panel, initialize panel with options as required, set up filter quickly.** 8 | 9 | #### Tutorial: 10 | 11 | Call factory method to initalize open panel instance. 12 | 13 | `+(instancetype)openPanelWithFilterOptions:(NSDictionary *)options.` 14 | 15 | In explanations of method shows the method requirations. 16 | 17 | **First**, you must set a `kFilterSizeKey` of the filter size with string value *(NSStringFromRect(FilterRect))*. 18 | 19 | **Second**, the dictionary other keys are the text show in the filter to help user understand fitler means. 20 | 21 | **Final**, the dictionary other values are the filter options, means the open panel allowed types. 22 | 23 | *Note :* 24 | 25 | ***If you want set open panel allowed types are all kinds. Set the array has no object not `nil`.*** 26 | 27 | 28 | ``` 29 | For example: 30 | 31 | NSDictionary * options = @{kFilterSizeKey : NSStringFromRect(NSMakeRect(0, 0, 200, 22)), @"MP4 Files(*.mp4, *.mov)" : @[@"mp4", @"mov"], @"All types.(*.*)" : @[]}; 32 | LOpenPanelWithFilter * op = [LOpenPanelWithFilter openPanelWithFilterOptions:options]; 33 | ``` 34 | 35 | Here is the result. 36 | 37 | ![](https://github.com/Kito0615/LOpenPanelAccessoryView/raw/master/.ss1.png) 38 | ![](https://github.com/Kito0615/LOpenPanelAccessoryView/raw/master/.ss2.png) 39 | ![](https://github.com/Kito0615/LOpenPanelAccessoryView/raw/master/.ss3.png) 40 | --------------------------------------------------------------------------------