• 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
beginSheet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

beginSheet


  • Subject: beginSheet
  • From: Livio <email@hidden>
  • Date: Thu, 25 May 2006 14:16:29 +0200

My purpose is to display a sheet dialog (something like the SavePanel).
I create a MyPanel object like this:

in file MyPanel.h:

@interface MyPanel : NSPanel
{
   void       *_panelData;
   NSButton   *_buttonOK;
}
- (IBAction)handlePanelActions:(id)sender;
- (void)setPanelData:(void *)panelData;

@end

@interface MyPanel(MyPanelRuntime)//if this makes sense...

- (void)runSheetPanel:(void *)panelData;

@end

in file MyPanel.h:


@implementation MyTPanel

- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag screen:(NSScreen *)aScreen {
self = [super initWithContentRect:contentRect styleMask:styleMask backing:bufferingType defer:flag screen:aScreen];
if (self)
{
NSArray *wArr;//just to get the the OKButton... not really elegant...
wArr = [[self contentView] subviews];
if ([wArr count])
{
_buttonOK = (NSButton *) [wArr objectAtIndex:1];
[_buttonOK setTarget:self];
[_buttonOK setAction:@selector(handlePanelActions:)];//I can't set it in InterfaceBuilder, right?
_panelData = nil;
}
else _buttonOK = nil;
}
return self;
}


- (void)setPanelData:(void*)panelData {
   //...
}

- (BOOL)getPanelData {
   //...
  return TRUE;
}

- (IBAction)handlePanelActions:(id)sender {
   if ([self getPanelData])
   {
       [self orderOut:nil];
       [NSApp endSheet:self];
   }
}

@end

@implementation MyPanel (MyPanelRuntime)

- (void)runSheetPanel:(void *)panelData {
_panelData = panelData;
[self setPanelData:_panelData];
[self setBecomesKeyOnlyIfNeeded:FALSE];
[NSApp beginSheet:self modalForWindow:[NSApp keyWindow] modalDelegate:nil didEndSelector:nil contextInfo:nil];
}


@end

It looks me more practical to put it all in a panel object, but before I put beginSheet and handlePanelActions in a MyWindowController, which loads the panel from the nib file.
In an earlier version I put it all in the object interface (I mean without @implementation MyPanel (MyPanelRuntime). In any case I' not sure of the label MyPanelRuntime).
I call beginSheet from another window's view.
Anyway it doesn't work: it stops after created and displayed the sheet returning with "error 11 (SIGSEGV)" or "signal 10 (SIGBUS)".
Can anybody tell me what happens?


Thanks a lot,
livio.
_______________________________________________
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


  • Follow-Ups:
    • Re: beginSheet
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: Best(simplest) way to implement iTunes like "link" buttons/icons
  • Next by Date: NSXLMDocument and malformed XML
  • Previous by thread: Best way to clean HTML str in ObjC
  • Next by thread: Re: beginSheet
  • Index(es):
    • Date
    • Thread