• 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: [SOLVED, with reservations] Re: Turn off menu highlight in outline view?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view?


  • Subject: Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view?
  • From: Graham Cox <email@hidden>
  • Date: Tue, 18 Aug 2009 21:50:32 +1000


On 18/08/2009, at 9:07 PM, I. Savant wrote:

It's not quite the same because a menu is another view and the table view is merely holding a reference to it. This is more an encapsulation problem.

Sorry for being so quick to "play the MVC card". ;-)


In a way though, I think you're right. MVC can be applied at many different levels, and within the microcosm of the table view in isolation, the menu and the table's current selection are part of its "model". In this case the menu is a data structure that supplies the relevant commands that the table can respond to at this moment in time. While there's not much you can do with it except display it or not, in theory that information could be presented quite differently.

Taking a slightly bigger view, it is an encapsulation problem too. It's unexpected, and a surprise to me, for sure, that -menuForEvent: is doing this drawing. So surprising that I had to carefully check my results before I really believed it.

Here's a fun little method I wrote to explore this - it just fakes an event that gradually tracks from the top of the table to the bottom. As you can see, you wouldn't really expect it to draw anything, but it does highlight each row in turn. The call to the window's - displayIfNeeded is required to flush the drawing out during the loop. <mLayersTable> is the ivar for the tableview (in fact an outline view - I haven't tested this against a table view).

- (void)			showMenuHighlightSideEffect
{
	NSEvent*	fakeMouseDown;
	NSPoint		mp;
	NSRect		tableFrame = [mLayersTable bounds];
	int		en = 12345;

	mp.x = NSMidX( tableFrame );
	mp.y = NSMinY( tableFrame );

	while( mp.y <= NSMaxY( tableFrame ))
	{
		NSPoint windowLocation = [mLayersTable convertPoint:mp toView:nil];

		fakeMouseDown = [NSEvent mouseEventWithType:NSRightMouseDown
					location:windowLocation
					modifierFlags:0
					timestamp:GetCurrentEventTime()
					windowNumber:[[mLayersTable window] windowNumber]
					context:[NSGraphicsContext currentContext]
					eventNumber:en++
					clickCount:1
					pressure:1.0];

		NSMenu* menu = [mLayersTable menuForEvent:fakeMouseDown];
		[[mLayersTable window] displayIfNeeded];

		NSLog(@"menu = %@", menu );

		mp.y++;
	}
}

--Graham



_______________________________________________

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: [SOLVED, with reservations] Re: Turn off menu highlight in outline view?
      • From: Graham Cox <email@hidden>
References: 
 >Turn off menu highlight in outline view? (From: Graham Cox <email@hidden>)
 >[SOLVED, with reservations] Re: Turn off menu highlight in outline view? (From: Graham Cox <email@hidden>)
 >Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view? (From: Corbin Dunn <email@hidden>)
 >Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view? (From: Graham Cox <email@hidden>)
 >Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view? (From: "I. Savant" <email@hidden>)
 >Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view? (From: "I. Savant" <email@hidden>)

  • Prev by Date: disabling tooltips table view
  • Next by Date: Re: disabling tooltips table view
  • Previous by thread: Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view?
  • Next by thread: Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view?
  • Index(es):
    • Date
    • Thread