I'm writing a signal processing program and I am trying to use a window to
display multiple NSViews of an oscilloscope, histograms, etc. I create the
NSTabViewItems programmatically. The window controller declares the following
properties:
@property(nonatomic, strong) IBOutlet NSWindow *analysis;
// the visualization window
@property(nonatomic, strong) IBOutlet NSTabView *myTabView;
// the host view
@property(nonatomic, strong) IBOutlet NSTabViewItem *scopeItem;
// the host view
@property(nonatomic, strong) IBOutlet NSTabViewItem *graphItem;
// the host view
@property(nonatomic, strong) IBOutlet NSTabViewItem *DSPItem;
// the host view
@property (nonatomic, strong) IBOutlet NSDrawer *scopeDrawer;
@property (nonatomic, strong) IBOutlet NSDrawer *graphFormatDrawer;
@property(nonatomic, strong) NSView *myCurrentView;
// the host view
@property(nonatomic, strong) NSViewController
*myCurrentViewController; // the current view controller
When I create the tab view items. I use in the window controller
-(void) awakeFromNib
{
[self setDelegate:self];
}
- (IBAction) viewScope:(id)sender
{
AppDelegate *appDelegate = [NSApp delegate];
if ([appDelegate oscilloscopeController] == nil){
[appDelegate setOscilloscopeController: [[OscilloscopeController
alloc]initWithNibName:@"OscilloscopeController" bundle:[NSBundle
bundleForClass:[OscilloscopeController class]]]];
NSLog(@"New Oscilloscope Controller Created by viewScope");
}
if ([appDelegate graphViewController] == nil) //Needed for
drawing grids, etc.
[appDelegate setGraphViewController: [[GraphViewController
alloc]initWithNibName:@"GraphViewController" bundle:[NSBundle
bundleForClass:[GraphViewController class]]]];
if ([[appDelegate oscilloscopeController] oScopeView] == nil){
[[appDelegate oscilloscopeController] setOScopeView:[[OscilloscopeView
alloc] initWithFrame: [[[appDelegate graphicsWindowController] myTabView]
contentRect]]];
NSLog(@"New Oscilloscope View Created by viewScope");}
if (!scopeItem){
[[appDelegate oscilloscopeController] initScopeSweep];
[[appDelegate graphicsWindowController] setScopeItem:
[(NSTabViewItem*)[NSTabViewItem alloc] initWithIdentifier:nil]];
[[[[appDelegate graphicsWindowController] scopeItem] view]
setAutoresizesSubviews:YES];
[[[appDelegate graphicsWindowController] scopeItem]
setLabel:@"Oscilloscope"];
[[[[appDelegate graphicsWindowController] scopeItem] view]
addSubview:(NSView*)[[appDelegate oscilloscopeController] oScopeView]];
[myTabView addTabViewItem:[[appDelegate graphicsWindowController]
scopeItem]];
}
[[[appDelegate graphicsWindowController]graphFormatDrawer] close];
[[[appDelegate graphicsWindowController]scopeDrawer] open];
[[appDelegate graphicsWindowController] setMyCurrentViewController:
[appDelegate oscilloscopeController]]; // keep track of the current view
controller
[[appDelegate graphicsWindowController] setMyCurrentView:
(NSView*) [[appDelegate oscilloscopeController] oScopeView]];
NSRect iRect = [[[appDelegate graphicsWindowController] myCurrentView]
bounds];
[[appDelegate oscilloscopeController] setDistOffset:(iRect.size.height/ 3)];
[[appDelegate oscilloscopeController] setProxOffset:((iRect.size.height /
3) * 2)];
[[[[NSApp delegate] graphicsWindowController] myCurrentView]
setNeedsDisplay:YES];
}
- (IBAction) viewGraph:(id)sender
{
AppDelegate *appDelegate = [NSApp delegate];
if ([appDelegate graphViewController] == nil)
[appDelegate setGraphViewController: [[GraphViewController
alloc]initWithNibName:@"GraphViewController" bundle:[NSBundle
bundleForClass:[GraphViewController class]]]];
if ([[appDelegate graphViewController] graphicsView] == nil){
[[appDelegate graphViewController] setGraphicsView:[[GraphicsView
alloc] initWithFrame: [[[appDelegate graphicsWindowController] myTabView]
contentRect]]];
NSLog(@"New Graphics View Created by viewGraph");}
if (![[appDelegate graphicsWindowController] graphItem]){
[[appDelegate graphicsWindowController] setGraphItem:
[(NSTabViewItem*)[NSTabViewItem alloc] initWithIdentifier:nil]];
[[[[appDelegate graphicsWindowController] graphItem] view]
setAutoresizesSubviews:YES];
[[[appDelegate graphicsWindowController] graphItem] setLabel:@"Graph"];
[[[[appDelegate graphicsWindowController] graphItem] view]
addSubview:(NSView*)[[appDelegate graphViewController] graphicsView]];
[myTabView addTabViewItem:[[appDelegate graphicsWindowController]
graphItem]];
}
[[[appDelegate graphicsWindowController]graphFormatDrawer] open];
[[[appDelegate graphicsWindowController]scopeDrawer] close];
[[appDelegate graphicsWindowController] setMyCurrentViewController:
[appDelegate graphViewController]]; // keep track of the current view
controller
[[appDelegate graphicsWindowController] setMyCurrentView:
(NSView*) [[appDelegate graphViewController] graphicsView]];
[[myCurrentViewController view] setFrame: [myCurrentView bounds]];
[[[[NSApp delegate] graphicsWindowController] myCurrentView]
setNeedsDisplay:YES];
}
I created a delegate procedure in the window controller
- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem
*)tabViewItem
{
AppDelegate *appDelegate = [NSApp delegate];
if (tabViewItem == [[appDelegate graphicsWindowController] scopeItem]){
NSLog(@"Scope Item Selected");
}
else if (tabViewItem == [[appDelegate graphicsWindowController] graphItem]){
NSLog(@"GraphItem Selected");
}
}
That never gets called. Hence my question about the target action of the tabs.
When I first create the oscilloscope tab the oscilloscope gets drawn,
but if I then create a graphViewItem it draws a blank screen. If I then click
on the oscilloscope tab, the oscilloscope image doesn't come back.
Thanks for your help.
Joseph
Joseph Ayers, Professor
Departments of Marine and Environmental Science
Biology, Civil and Environmental Engineering
and Marine Science Center
Northeastern University
East Point, Nahant, MA 01908
Phone (781) 581-7370 x309(office), x335(lab)
Boston: 444 Richards Hall (617) 373-4044
Cellular (617) 755-7523, FAX: (781) 581-6076
eMail: [email protected]
http://www.neurotechnology.neu.edu/
http://robobees.seas.harvard.edu/
http://cyberplasm.net/
On Sep 12, 2013, at 10:09 AM, Graham Cox <[email protected]> wrote:
>
> On 12/09/2013, at 3:22 PM, Joseph Ayers <[email protected]> wrote:
>
>> When you click on a tab in a NSTabView, what action gets sent to what target?
>> Where can I find this information?
>
>
> I don't think actions or targets are involved. The NSTabViewItem clickable
> button row appears to be privately managed and operates purely internally.
>
> What are you trying to do? There may be another way, e.g. override [NSTabView
> selectTabViewItem:] though that particular case is better handled by using a
> delegate.
>
> --Graham
>
>
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]