• 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: shouldSelectTabViewItem called twice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shouldSelectTabViewItem called twice


  • Subject: Re: shouldSelectTabViewItem called twice
  • From: Frode <email@hidden>
  • Date: Tue, 27 Jun 2006 11:13:38 +0200

Part 3 of 3

8. Quit Interface Builder and go to XCode. Paste this source code in MyDocument.h

	NSButton *checkbox1;
	NSWindow *mainWindow;
	NSButton *previousButton, *nextButton;

9. Paste this source code in MyDocument.m

- (void)tabView:(NSTabView *)tabView willSelectTabViewItem: (NSTabViewItem *)tabViewItem {
NSLog (@"%s:%@", __func__, [tabViewItem identifier]);
int idx = [tabView indexOfTabViewItem:tabViewItem];
[previousButton setEnabled:idx != 0];
[nextButton setEnabled:idx != [tabView numberOfTabViewItems] - 1];
}


- (void)tabView:(NSTabView *)inTabView didSelectTabViewItem: (NSTabViewItem *)tabViewItem {
NSLog (@"%s:%@", __func__, [tabViewItem identifier]);
}


- (BOOL)tabView:(NSTabView *)inTabView shouldSelectTabViewItem: (NSTabViewItem *)tabViewItem {
NSLog (@"%s:%@", __func__, [tabViewItem identifier]);
switch ([[[inTabView selectedTabViewItem] identifier] intValue]) {
case 1:
if ([checkbox1 state] > 0) {
NSBeginAlertSheet(@"Page locked",
@"OK", nil, nil, mainWindow, nil, nil,
NULL, NULL, @"Uncheck to switch page", nil);
return NO;
}
return YES;
default:
return YES;
}
return YES;
}


10. Compile, run and read the log. Test first switching pages by the next and previous button. The shouldSelectTabViewItem is called twice. Then, switch pages by the tab-view buttons named "tab" and "view" and notice shouldSelectTabViewItem is called only once.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >shouldSelectTabViewItem called twice (From: Frode <email@hidden>)

  • Prev by Date: Re: shouldSelectTabViewItem called twice
  • Next by Date: Beginner Question About CustomView, -drawRect: and Plotting Data.
  • Previous by thread: Re: shouldSelectTabViewItem called twice
  • Next by thread: Re: shouldSelectTabViewItem called twice
  • Index(es):
    • Date
    • Thread