Hi,

I have it working now.  Changed the NSView to a NSWindowController and is 
working fine.

Regards,

Ben Martin

TruStorm Software
http://www.trustorm.com.au
0407 256 072
________________________________________
From: Ben Martin [EMAIL PROTECTED]
Sent: Friday, 8 August 2008 9:52 AM
To: [email protected]
Subject: RE: [EMAIL PROTECTED] Simple Modal Window

Hi,

Here is the code I am trying to use.

>From Document Controller:
[ObjectiveCMessage("newDocument:")]
        public override void NewDocument(Id sender)
        {
            NewForm oNewField = NewForm.Create();

            if (oNewField != null)
            {
                
NSApplication.SharedApplication.RunModalForWindow(oNewField.buttonCancel.Window);
            }
        }

The subclass:
[ObjectiveCClass]
    public class NewForm: NSView
    {
        private static readonly Class NewFormClass = 
Class.GetClassFromType(typeof(NewForm));
        public NewForm() {}
    public NewForm(IntPtr np) : base(np) {}
        public NewForm(NSString nibName, NSBundle bundle) : base(nibName, 
bundle) { }
        [ObjectiveCField]
        public NSButton buttonCancel;
        [ObjectiveCField]
        public NSButton buttonNew;

        [ObjectiveCMessage("awakeFromNib")]
        public void awakeFromNib()
        {
            Console.WriteLine("NewFieldController: awakeFromNib");
        }
        [ObjectiveCMessage("buttonNew_Clicked:")]
        public void ButtonNewClicked(Id sender)
        {
            // Use a standard alert to display the message
            AppKitFramework.NSRunAlertPanel("buttonNewClicked", "New button 
clicked", "OK", null, null);
        }
        [ObjectiveCMessage("buttonCancel_Clicked:")]
        public void ButtonCancelClicked(Id sender)
        {
            // Use a standard alert to display the message
            AppKitFramework.NSRunAlertPanel("buttonCancelClicked", "Cancel 
button clicked", "OK", null, null);
        }

        public static NewForm Create()
        {
//NewForm is the name of the NIB.
            return new NewForm(new NSString("NewForm"), NSBundle.MainBundle);
        }
    }



Regards,

Ben Martin

TruStorm Software
http://www.trustorm.com.au
0407 256 072
________________________________________
From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of Laurent Etiemble [EMAIL 
PROTECTED]
Sent: Monday, 4 August 2008 6:30 PM
To: [email protected]
Subject: Re: [EMAIL PROTECTED] Simple Modal Window

Hello,

Can you describe it bit more the context ?
Are you trying to create a new NSWindow programmaticaly or by loading a NIB ?
Can you post the snippet of code that leads to the error ?
Have you take a look at
http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/WinPanel.pdf
?

Regards, Laurent Etiemble

2008/8/4 Ben Martin <[EMAIL PROTECTED]>:
> Hi,
>
> I am finding it difficult to create a custom modal window for my application
> (new document selection window).  I have tried looking at the apple doc's
> with no luck.
>
> The main problem is creating the instance in .NET and load the nib file.
> The consol shows the error "Selector not recognized [self = 0xb7a0940]"
>
> Any help would be good.
>
>
>
> Regards,
>
>
>
> Ben Martin
>
>
>
> TruStorm Software
>
> http://www.trustorm.com.au
>
> 0407 256 072

Reply via email to