Permalink
Browse files

moved the control event sending into TUIControl

  • Loading branch information...
1 parent e4f0d99 commit e6237416869a9e1a092e8e6228c74f1b9536a891 @joshaber joshaber committed Aug 15, 2011
Showing with 17 additions and 33 deletions.
  1. +1 −20 lib/UIKit/TUIButton.m
  2. +16 −13 lib/UIKit/TUIControl.m
View
@@ -215,12 +215,7 @@ - (void)drawRect:(CGRect)r
- (void)mouseDown:(NSEvent *)event
{
[super mouseDown:event];
- if([event clickCount] < 2) {
- [self sendActionsForControlEvents:TUIControlEventTouchDown];
- } else {
- [self sendActionsForControlEvents:TUIControlEventTouchDownRepeat];
- }
-
+
if(popUpMenu) { // happens even if clickCount is big
NSMenu *menu = popUpMenu;
NSPoint p = [self frameInNSView].origin;
@@ -240,20 +235,6 @@ - (void)mouseDown:(NSEvent *)event
}
}
-- (void)mouseUp:(NSEvent *)event
-{
- [super mouseUp:event];
-// if([event clickCount] < 2) {
- if([self eventInside:event]) {
- if(![self didDrag]) {
- [self sendActionsForControlEvents:TUIControlEventTouchUpInside];
- }
- } else {
- [self sendActionsForControlEvents:TUIControlEventTouchUpOutside];
- }
-// }
-}
-
- (void)_update {
_titleView.text = self.currentTitle;
_titleView.textColor = self.currentTitleColor;
@@ -95,9 +95,9 @@ -(BOOL)selected {
*/
-(void)setSelected:(BOOL)selected {
[self _stateWillChange];
- _controlFlags.selected = selected;
+ _controlFlags.selected = selected;
[self _stateDidChange];
- [self setNeedsDisplay];
+ [self setNeedsDisplay];
}
- (BOOL)acceptsFirstMouse
@@ -124,12 +124,15 @@ - (void)mouseDown:(NSEvent *)event
_controlFlags.tracking = 1;
[self _stateDidChange];
- // handle touch down
- [self sendActionsForControlEvents:TUIControlEventTouchDown];
+ // handle touch down
+ if([event clickCount] < 2) {
+ [self sendActionsForControlEvents:TUIControlEventTouchDown];
+ } else {
+ [self sendActionsForControlEvents:TUIControlEventTouchDownRepeat];
+ }
// needs display
[self setNeedsDisplay];
-
}
- (void)mouseUp:(NSEvent *)event
@@ -141,16 +144,16 @@ - (void)mouseUp:(NSEvent *)event
_controlFlags.tracking = 0;
[self _stateDidChange];
- // handle touch up
- if([self pointInside:[self localPointForEvent:event] withEvent:event]){
- [self sendActionsForControlEvents:TUIControlEventTouchUpInside];
- }else{
- [self sendActionsForControlEvents:TUIControlEventTouchUpOutside];
- }
+ if([self eventInside:event]) {
+ if(![self didDrag]) {
+ [self sendActionsForControlEvents:TUIControlEventTouchUpInside];
+ }
+ } else {
+ [self sendActionsForControlEvents:TUIControlEventTouchUpOutside];
+ }
- // needs display
+ // needs display
[self setNeedsDisplay];
-
}
@end

0 comments on commit e623741

Please sign in to comment.