Comments (12)
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?
from twui.
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...
from twui.
Oh I understand...
You could try to use isPointInside inside mouseExited to check if the pointer really exited the tableviewcell like:
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!
from twui.
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.
}
}
from twui.
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 think we should find a better way.
from twui.
I added below code to avoid this problem, just like most app does :P
- (void)scrollWheel:(NSEvent *)theEvent {
[super scrollWheel:theEvent];
isMouseInside = NO;
}
from twui.
Are you sure this solves the problem? Because just tested it and it doesn't work! That method gets called only when you scroll.
from twui.
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.
from twui.
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 .
from twui.
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.
from twui.
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];
from twui.
Here is how I handled that in a simple view
- (void) userIsHovering {
if (_tracking) {
[self setControlsHidden:NO];
}
}
- (void) mouseEntered:(NSEvent *)theEvent {
_tracking = YES;
[self performSelector:@selector(userIsHovering) withObject:nil afterDelay:0.9];
}
- (void) mouseEntered:(NSEvent *)event onSubview:(TUIView *)subview {
_tracking = YES;
_trackingSubview = YES;
}
-(void) mouseExited:(NSEvent *)event fromSubview:(TUIView *)subview {
_trackingSubview = NO;
}
- (void) mouseExited:(NSEvent *)theEvent {
if (!_trackingSubview) {
_tracking = NO;
}
if (!collapsed && !_tracking) {
[self setControlsHidden:YES];
}
}
from twui.
Related Issues (20)
- TUITableView cell queue fix HOT 2
- TUIControl tracking and events HOT 2
- TUIImage for animated gif? HOT 3
- Dictionary popup of TUITextRenderer does not work on 10.7.3? HOT 11
- Lots of commits recently... time to spin a new release? HOT 2
- compile error HOT 2
- A "getting started" guide would be great HOT 12
- TUIPopover issues HOT 5
- Goal of twui ? HOT 2
- Core Layout HOT 7
- Missing features + updates HOT 3
- UIKit / iOS support? HOT 7
- Vector Graphics HOT 9
- Appearances
- Table view cell drawing not updated correctly. HOT 1
- Crash when window is released
- TUIScrollView - Indicators not visible while dragging when set to show while scrolling HOT 1
- TUILabel - jagged text when background color is clearColor HOT 3
- TUIImage imageName could not accept image name without extention
- Scroll View in reverse? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twui.