Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Smooth Resizing (again)



Thanks John,

I'm getting very, very close now. It compiles properly now with the
amendments made but I get a "NS InternalScriptError (8)" with the
message:
" -[NSCFString frame]: selector not recognized" in the log window.

Here's the snippet of AS code I'm using:

on clicked theObject
tell window "w_main"
if name of theObject is "size" then
my resize()
end if
end tell
end clicked

on resize()
call method "resizeWindow:toHeight:toWidth:" of class "CocoaUtilities"
with parameters {"w_main", 400, 400}
end resize

> Right, sorry - the .h file should contain:
> #import <Cocoa/Cocoa.h>
>
> That should bring in all the classes you need to define the objects and
> functions that are causing you trouble.
>
> Your reference to a window in AppleScript can be handed straight to
> this
> method as the argument - Studio automagically handles the transition
> gracefully (for windows, at least).
>
> As an aside, by the way you wrote it, the .h file seems to be importing
> itself - I'm assuming that's inaccurate, but you should get rid of
> that if
> it isn't.
>
> JT
>
>
>> Thanks for your input, much appreciated, but a bit more help would be
>> needed for me to get it working.
>> I'm getting closer (I think) but obviously missing something.
>>
>> So far I've created a Cocoa class and added the 2 files (.h and .m) in
>> the 'Resources' folder of my application.
>>
>> File called 'CocoaUtilities.h' as the following:
>>
>> #import <CocoaUtilities.h>
>>
>> @interface CocoaUtilities : NSObject {
>>
>> }
>>
>> + (void)resizeWindow :(NSWindow *)window toHeight :(int)height
>> toWidth:(int)width;
>>
>> @end
>>
>> Then I've got 'CocoaUtilities.m' which has the following:
>>
>> #import "CocoaUtilities.h"
>>
>> @implementation CocoaUtilities
>>
>> + (void)resizeWindow :(NSWindow *)window toHeight :(int)height toWidth
>> :(int)width
>>
>> {
>> NSRect windowFrame,newWindowFrame;
>> windowFrame = [NSWindow contentRectForFrameRect:[window frame]
>> styleMask:[window styleMask]];
>> newWindowFrame = [NSWindow
>> frameRectForContentRect:NSMakeRect(NSMinX(windowFrame),NSMaxY(windowFr
>> am
>> e) - height,width,height) styleMask:[window styleMask]];
>>
>> [window setFrame:newWindowFrame display:YES animate:YES];
>> }
>>
>> @end
>
>
>

--
Guy
mailto:email@hidden
_______________________________________________
applescript-studio mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-studio
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Smooth Resizing (again) (From: John Timmer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.