• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSButtonCell mouseEntered/mouseExited stops after view is swapped out ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSButtonCell mouseEntered/mouseExited stops after view is swapped out ...


  • Subject: Re: NSButtonCell mouseEntered/mouseExited stops after view is swapped out ...
  • From: Martin Redington <email@hidden>
  • Date: Tue, 3 Jul 2007 15:45:25 +0100


On 3 Jul 2007, at 15:12, PGM wrote:


I'm seeing NSButtonCell stop acknowledging mouseEntered/ mouseExited events after its superview is removed from, and then re-added to a window.


I have a window whose contentViews can be switched. The contentViews contain buttons that initiate the switching.

I subclassed NSButton and NSButtonCell, so that I could over-ride NSButtonCell's mouseEntered and mouseExited methods (I want to update my UI when this happens - why isn't important).

Everything works absolutely fine, and I can see mouseEntered/ Exited firing off happily.

I switch to the other view. Again, the mouseEntered/mouseExited methods for its button cell fire off no problem.

I switch back to the original view - mouseEntered/mouseExited no longer work on either button.

I've posted the actual code below.

Any suggestions or workarounds would be great.

   cheers,
           m.


Did you update the trackingRects/cursorRects for your NSButton?

http://developer.apple.com/documentation/Cocoa/Conceptual/ EventOverview/MouseTrackingEvents/chapter_7_section_2.html

Nope. Do I need to do that manually (with NSButton/NSButtonCell)?

I just tried covering add and removeTrackingRect in the button subclass, so I could see when they're getting called. Output follows below.

First time around, the tracking rects get added properly, and they get updated on removal, but on readdition, they don't get added again. I'll see if I can add the tracking rects manually the second time around, although if I have to manage the tracking rect tag myself, I may also have to handle removal manually too. It may be easier to just try creating a new replacement button.

This definitely seems like a bug to me (and I actually just filed it as 5309490 just before I read your reply). If the tracking rect gets added manually first time around, then when the button cell is removed, it should go back to its initial state, and the tracking rect should get added automatically again next time. If anyone knows how to force the button back to it's initial state, that would be great.

Its obviously trying to clean up the tracking rects automatically when it gets removed, judging from the output below ...


[Session started at 2007-07-03 15:30:13 +0100.]

# first view added to window in awakeFromNib
2007-07-03 15:30:13.638 ButtonCellIssue[23966] addTrackingRect called for <MyButton: 0x3260d0> Button One


# move the mouse over button one, and click. view one removed, view two added
2007-07-03 15:30:20.361 ButtonCellIssue[23966] Mouse Entered <MyButtonCell: 0x308bc0> Button One


# why does it get removed, added, and removed?
2007-07-03 15:30:20.917 ButtonCellIssue[23966] removeTrackingRect called for <MyButton: 0x3260d0> Button One
2007-07-03 15:30:20.917 ButtonCellIssue[23966] addTrackingRect called for <MyButton: 0x3260d0> Button One
2007-07-03 15:30:20.917 ButtonCellIssue[23966] removeTrackingRect called for <MyButton: 0x3260d0> Button One


# view two is added
2007-07-03 15:30:20.917 ButtonCellIssue[23966] addTrackingRect called for <MyButton: 0x343330> Button Two
2007-07-03 15:30:22.338 ButtonCellIssue[23966] Mouse Exited <MyButtonCell: 0x3434b0> Button Two


# move the mouse back onto the button and click again
2007-07-03 15:30:41.455 ButtonCellIssue[23966] Mouse Entered <MyButtonCell: 0x3434b0> Button Two
2007-07-03 15:30:42.230 ButtonCellIssue[23966] removeTrackingRect called for <MyButton: 0x343330> Button Two
2007-07-03 15:30:42.230 ButtonCellIssue[23966] addTrackingRect called for <MyButton: 0x343330> Button Two
2007-07-03 15:30:42.230 ButtonCellIssue[23966] removeTrackingRect called for <MyButton: 0x343330> Button Two


# but addTrackingRect does not get called for button one ...








Good luck, Patrick


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSButtonCell mouseEntered/mouseExited stops after view is swapped out ... [WORKAROUND]
      • From: Martin Redington <email@hidden>
References: 
 >NSButtonCell mouseEntered/mouseExited stops after view is swapped out ... (From: Martin Redington <email@hidden>)
 >Re: NSButtonCell mouseEntered/mouseExited stops after view is swapped out ... (From: PGM <email@hidden>)

  • Prev by Date: Re: outdated link in Cocoa documentation
  • Next by Date: Re: drag & drop objects
  • Previous by thread: Re: NSButtonCell mouseEntered/mouseExited stops after view is swapped out ...
  • Next by thread: Re: NSButtonCell mouseEntered/mouseExited stops after view is swapped out ... [WORKAROUND]
  • Index(es):
    • Date
    • Thread