mouseEntered strange (or not) behavior

34 views
Skip to first unread message

Didier Korthoudt

unread,
Oct 28, 2015, 4:11:51 PM10/28/15
to Cappuccino & Objective-J
Hi there !

While implementing a mouseEntered on a CPView subclass, I found what I think is a strange (abnormal ?) behavior... Or not.

I noticed that the method is called multiple times while entering the view.

I digged a little and found that it is called as many times as the number of views, subviews, subsubviews are under the mouse.

To be clear, if a view contains another view filling all the superview (for example), then moving the pointer over it fires 2 mouseEntered events on the superview.

I then made the little test case here above and found that if you enter the red square, you get a fire. Entering next the green square, you get a second fire.

This seems weird to me as the pointer doesn't quit and re-enter the red square.

As the green one is a simple view (not the subclass implemented the mouseEntered), it doesn't have to fire anything...

So, bug or feature ?

Thanks !


Didier.


Sample test case :

@import <Foundation/Foundation.j>

@import <AppKit/AppKit.j>


@class SomeViewSubclass;


@implementation AppController : CPObject

{

    @outlet CPWindow    theWindow;

}


- (void)applicationDidFinishLaunching:(CPNotification)aNotification

{

    // This is called when the application is done loading.

}


- (void)awakeFromCib

{

    // This is called when the cib is done loading.

    // You can implement this method on any object instantiated from a Cib.

    // It's a useful hook for setting up current UI values, and other things.


    // In this case, we want the window from Cib to become our full browser window

    [theWindow setFullPlatformWindow:NO];

    

    var aView = [[SomeViewSubclass alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];

    

    [aView setBackgroundColor:[CPColor redColor]];

    

    [[theWindow contentView] addSubview:aView];

    

    var anotherView = [[CPView alloc] initWithFrame:CGRectMake(10, 10, 30, 30)];

    

    [anotherView setBackgroundColor:[CPColor greenColor]];

    

    [aView addSubview:anotherView];

}


@end



@implementation SomeViewSubclass : CPView

{

    

}


- (void)mouseEntered:(CPEvent)anEvent

{

    CPLog.trace("mouseEntered");

}



@end


Didier Korthoudt

unread,
Oct 28, 2015, 4:13:32 PM10/28/15
to Cappuccino & Objective-J
Of course, it's "here under" and not "here above"...

Aparajita Fishman

unread,
Oct 28, 2015, 4:47:38 PM10/28/15
to objec...@googlegroups.com
> So, bug or feature ?

Bug. I remember looking at fixing mouse tracking a long time ago, but gave up in the end with the idea that we would implement the modern Cocoa way of mouse tracking which is NSTrackingArea. But that never happened.

Regards,

Aparajita


Didier Korthoudt

unread,
Oct 29, 2015, 3:42:46 AM10/29/15
to Cappuccino & Objective-J
Hi Aparajita !

Thank you for your answer.

Do you want me to fill an issue ?

Have a nice day,


Didier.

Aparajita Fishman

unread,
Oct 29, 2015, 10:07:06 AM10/29/15
to objec...@googlegroups.com
> Do you want me to fill an issue ?

Sure, go ahead. Please provide a sample app.

Regards,

Aparajita
Cappuccino Core Team


Didier Korthoudt

unread,
Oct 29, 2015, 5:54:52 PM10/29/15
to Cappuccino & Objective-J
Dear Aparajita,

I've filled an issue with a sample app.

I've also searched by myself.

For what I've seen, the problem is that 2 mechanisms are dealing with the event propagation : the window sendEvent that sends to every view where the event happens, and the responder mechanism (not yet really studied) that propagates down unmanaged events (that is, if I'm a view and if I don't have a specific mouseEntered method, then I propagate the event to my next responder).

And then, for what I understand, some views in the hierarchy get the event by the window sendEvent mechanism AND by the hierarchy propagation.

To check this, I've modified the sendEvent method and it gets better.

It's not the ultimate solution because some cases are not well managed.

I continue searching...

Didier Korthoudt

unread,
Oct 29, 2015, 7:23:37 PM10/29/15
to Cappuccino & Objective-J
OK. I think I've a solution (not necessary THE solution).

I asked on the issue how to propose it...

Aparajita Fishman

unread,
Oct 29, 2015, 8:12:40 PM10/29/15
to objec...@googlegroups.com
Awesome! I'll take a look at it tomorrow.

> On Oct 29, 2015, at 7:23 PM, Didier Korthoudt <didier.k...@ulg.ac.be> wrote:
>
> OK. I think I've a solution (not necessary THE solution).
>
> I asked on the issue how to propose it...

Regards,

Aparajita


Didier Korthoudt

unread,
Oct 30, 2015, 6:08:16 AM10/30/15
to Cappuccino & Objective-J
Dear Aparajita,

I've just pushed my proposal.

I hope this will be OK. I've done some tests on my main application and it seems to work correctly but I didn't do every possible tests.

I'll check further tonight.

Best Regards,


Didier.
Reply all
Reply to author
Forward
0 new messages