Hi,


Does anyone have a good snippet of example code for calling NSOpenPanel with CamelBones?

I am not certain what the syntax should be and there are few examples I can find.

Did you check Apple's Cocoa Documentation?
Since CamelBones just wraps around the Objective-C functions, you can use the documentation for that.



For starters, you can do something like this:

my $panel = NSOpenPanel->openPanel;
if ($panel->runModal) {
        # user clicked "Open"
        my $files = $panel->filenames;
        # get only one file here
         my $file = $files->lastObject;
        
        # .. do something with $file (the file name)
}
else{
        # user clicked cancel

}

There is also NSSavePanel to save files (rather than open them).

If you want to filter for specific files types you can do:


 my $types = NSMutableArray->alloc->init;
    $types->addObject('pod');
    $types->addObject('pm');
    $types->addObject('pl');

    my $panel = NSOpenPanel->openPanel;

if ($panel->runModalForTypes($types)) {



Hope it helps,

Thilo



Reply via email to