Skip to main content
Inspiring
September 20, 2011
Question

Qt or Cocoa GUI for a plugin: A short tutorial requested.

  • September 20, 2011
  • 1 reply
  • 2219 views

Would anyone be so kind to write a short tutorial on how to create a simple dialog in an Illustrator plugin using either Qt or Cocoa.

As of now, I have experience in plugin development using ADM.

I have some experience in Cocoa programming.

I have no experience in Qt.

CONCERNING COCOA:

I have managed to write som code and bring up a simple Cocoa window from my plugin.  But the window is set to be visible at launch and it appears once the plugin is is loaded.

Action methoda in the controller class also correctly get called upon buton presses and such like.

I've written wrapper function according to the Carbon-Cocoa Integration Guide.  But, I'm unable to hide/show the window programatically.

CONCERNING Qt:

I simply don't know where to start...

A simple tutorial for either case would be lovely...

Agnar

This topic has been closed for replies.

1 reply

September 20, 2011

For Cocoa I do this:

- (id)init {

    if (self = [super initWithWindowNibName:@"windowNIBName"]) {

       //Do any init here

          }

    return self;

}

To bring up the window;

          NSWindow* w = [self window];

          [NSApp runModalForWindow:w];

Then when I want to close it:

[[self window] performClose:self];

Hope that helps some.

arenolAuthor
Inspiring
October 5, 2011

And how do you create an instance of your Windows Controller class?

Do you create one global windows controller instance  at the startup of the Plugin or do you create one every time you want to open the window?

arenolAuthor
Inspiring
October 6, 2011

It seems that I made things working now.

I have more or less ignored the Cocoa-Carbon integration stuff(particularly concerning the autorelease pool).

Each time I need to open a dialog, I create an instance of my NSWindowController subclass.  I relase it when I close the window, Hence:

/* Standard C-wrapper function to open a dialog */

short

ShowDialog( void)

{

    MyWindowController* dlgController = [[MyWindowController alloc] init];

    [dlgController showWindow];

    return noErr;

}

/* MyWindowController methods */

- (void) showWindow

{

    NSWindow* w = [self window];

    /* The function RunAppModalLoopForWindow will automatically establish and drain an

       NSAutoReleasePool. That probably implies that we don't need to bother creating

       such a pool in our wrapper function */

    [NSApp runModalForWindow: w];

}

- (IBAction) closeDialog: (id) sender

{

    [[self window] performClose: self];

    [self release];

    [NSApp stopModal];

}