Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 62 lines (49 sloc) 2.444 kb
a97362f @steipete initial commit
authored
1 // PSMenuItem.h
2 //
3 // Copyright (c) 2012 Peter Steinberger (http://petersteinberger.com)
4 // This code is a part of http://pspdfkit.com and has been put under MIT license.
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 // THE SOFTWARE.
23
24 #import <UIKit/UIKit.h>
25
26 /**
27 This subclass adds support for a block-based action on UIMenuItem.
28 If you are as annoyed about the missing target/action pattern, you will love this.
29
30 If you use PSMenuItem with the classic initWithTitle:selector initializer,
31 this will work and be handled just like a UIMenuItem.
32 */
33 @interface PSMenuItem : UIMenuItem
34
35 // Initialize PSMenuItem with a block.
36 - (id)initWithTitle:(NSString *)title block:(void(^)())block;
37
38 // Menu Item can be enabled/disabled. (disable simply hides it from the UIMenuController)
39 @property(nonatomic, assign, getter=isEnabled) BOOL enabled;
40
41 // Action block.
42 @property(nonatomic, copy) void(^block)();
43
44
45 /**
46 Installs the menu handler. Needs to be called once per class.
47 (A good place is the +load method)
48
49 Following methods will be swizzled:
50 - canBecomeFirstResponder (if object doesn't already return YES)
51 - canPerformAction:withSender:
52 - methodSignatureForSelector:
53 - forwardInvocation:
54
55 The original implementation will be called if the PSMenuItem selector is not detected.
56
57 @parm object can be an instance or a class.
58 */
59 + (void)installMenuHandlerForObject:(id)object;
60
61 @end
Something went wrong with that request. Please try again.