Permalink
Browse files

DimsWhenHighlighted property in TUIButton

  • Loading branch information...
1 parent ed322c8 commit 4920f13dddfaa4d5556b2bdcfe43820a26b1a86a @michaelvillar committed May 9, 2012
Showing with 5 additions and 0 deletions.
  1. +1 −0 lib/UIKit/TUIButton.h
  2. +4 −0 lib/UIKit/TUIButton.m
View
@@ -54,6 +54,7 @@ typedef enum {
@property(nonatomic,assign) TUIEdgeInsets titleEdgeInsets;
@property(nonatomic,assign) TUIEdgeInsets imageEdgeInsets;
@property(nonatomic,assign) BOOL dimsInBackground;
+@property(readwrite) BOOL dimsWhenHighlighted;
@property(nonatomic,readonly) TUIButtonType buttonType;
View
@@ -29,6 +29,7 @@ - (void)_update;
@implementation TUIButton
@synthesize popUpMenu;
+@synthesize dimsWhenHighlighted;
- (id)initWithFrame:(CGRect)frame
{
@@ -39,6 +40,7 @@ - (id)initWithFrame:(CGRect)frame
_buttonFlags.buttonType = TUIButtonTypeCustom;
_buttonFlags.dimsInBackground = 1;
_buttonFlags.firstDraw = 1;
+ self.dimsWhenHighlighted = NO;
}
return self;
}
@@ -165,6 +167,8 @@ - (void)drawRect:(CGRect)r
BOOL key = [self.nsWindow isKeyWindow];
CGFloat alpha = 1.0;
+ if(self.dimsWhenHighlighted && self.state == TUIControlStateHighlighted)
+ alpha = 0.5;
if(_buttonFlags.dimsInBackground)
alpha = key?alpha:0.5;

0 comments on commit 4920f13

Please sign in to comment.