Qt or Cocoa GUI for a plugin: A short tutorial requested.
Copy link to clipboard
Copied
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
Explore related tutorials & articles

Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I Pressume "self" is referring to (an instance) of NSWindowsController (sub-)class?
Is any of the stuff in this Cocoa-Carbon integration guide relevant to Illustrator plugins (Illustrator is Carbon, isn't it?)
Agnar
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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];
}

