-
Notifications
You must be signed in to change notification settings - Fork 268
MouseExited called when mouse enter subview #61
Comments
Can you post your code please? Right now I can't reproduce your problem. Are you tracking the subview with mouseEntered:onSubview: or you set the delegate to the tableviewcell view? |
Like Twitter for Mac, If I move cursor to a cell , will call cell's mouseEntered: method.Then I move cursor to a profile image , mouseExited: will be called , I don't wanna this happen . in my TUITableViewCell subclass: - (void)mouseEntered:(NSEvent *)theEvent{
[super mouseEntered:theEvent];
isMouseInside = YES;
}
- (void)mouseExited:(NSEvent *)theEvent{
[super mouseExited:theEvent];
isMouseInside = NO;
} move cursor to profile image will set isMouseInside to NO... |
Oh I understand... if([self pointInside:[self localPointForEvent:theEvent] withEvent:theEvent]) {
NSLog(@"You're still inside the cell!");
} But actually I'm not sure if this is the best way! |
Thanks~ I'm coding like this now: - (void)mouseExited:(NSEvent *)theEvent{
if (![self eventInside:theEvent]) {
isMouseInside = NO;
[TUIView animateWithDuration:0.3 animations:^{
[self redraw];
}];
}
else{
// mouse still inside.
}
} |
The downside of this solution is that if the mouse exits from the part where is located the scroll knob the appellation will think that the mouse is still inside..... |
I added below code to avoid this problem, just like most app does :P - (void)scrollWheel:(NSEvent *)theEvent {
[super scrollWheel:theEvent];
isMouseInside = NO;
} |
Are you sure this solves the problem? Because just tested it and it doesn't work! That method gets called only when you scroll. |
Only wanted to note that I solved using view:mouseEntered and view:mouseExited. It's more like a hack than a solution but it works pretty well and I think it's the way Twitter for mac uses. |
How did you done this? in TUIView+Event.m - (void)mouseExited:(NSEvent *)event
{
if(self.superview != nil){
[self.superview mouseExited:event fromSubview:self];
}
if(_viewFlags.delegateMouseExited){
[_viewDelegate view:self mouseExited:event];
}
} I have noticed it , but it seems only call in - (void)mouseExited:(NSEvent *)event , and pass cell self to delegate . |
You just need to create another instance variable isMouseInsideSubview and then use it to check if we are inside a subview setting its value by subclassing the methods -(void)view:(TUIView *)v mouseEntered:(NSEvent *)event
{
ismouseinsidesubview=YES;
}
-(void)view:(TUIView *)v mouseExited:(NSEvent *)event
{
ismouseinsidesubview=NO;
} and later checking this value inside the mouseExited:(NSEvent *)event and mouseEntered:(NSEvent *)event. Another way to accomplish the same result is to set the subviews inside the the main cell view userinteractionenabled=NO and then react to the events relative to them by using the point inside method, just like it's done for the scroll knob. |
Thanks~~ I'v done it too~ you can simply move ismouseinsidesubview=YES; to - (void)mouseEntered:(NSEvent *)event onSubview:(TUIView *)subview{
if (!_cellFlags.isMouseInSubView) {
_cellFlags.isMouseInSubView = YES;
}
if (!_cellFlags.isMouseInside) {
_cellFlags.isMouseInside = YES;
[self updateViewAnimated];
}
} that delegate method called in cell's [super mouseEntered:theEvent]; |
Here is how I handled that in a simple view
|
Every time I move cursor into a TUITableViewCell's subview, TUIView will call cell's mouseExited. but cursor is still in cell. Is there any way to know when cursor exited the cell to another cell. Thanks!
The text was updated successfully, but these errors were encountered: