 |
 |
A "smooth" resize in AS-Studio ?
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: The Land of Beer and Chocolates
Status:
Offline
|
|
I was wondering how you can make a window resize , but smoothly like in System Prefs .
Basically , I would want to tell a window "smooth resize to (300,400)" (you get the idea) .
Is that possible in AS-Studio ?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Status:
Offline
|
|
Create Application.h and Application.m files using the standard NSApplication headers. Create a new method in Application.m:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
- (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(windowFr ame) - width,NSMaxY(windowFrame) - height,width,height) styleMask:[window styleMask]];
[window setFrame:newWindowFrame display:YES animate:YES];
}
</font>[/code]
And add it to the header file as well. This should work (if it doesn't change "NSMinX(windowFrame) - width" to "NSMinX(windowFrame)"--it's from memory. Just call this from your AS-S app:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
call method <font color = red>"resizeWindow:toHeight:toWidth:"</font>with parameters {window "MyProjectWindow, <font color = blue>212</font>, <font color = blue>345</font>}
</font>[/code]
as an example.
[ 02-08-2002: Message edited by: Ibson ]
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: The Land of Beer and Chocolates
Status:
Offline
|
|
Thanks for the reply , but I can't figure out how to get it to work
Could you post exactly what I should write in the Application.h and Application.m files ?
Thanks
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Status:
Offline
|
|
Sorry  --here's the full listing:
Application.h:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
#import <AppKit/AppKit.h>
@interface NSApplication (ApplicationName)
- (void)resizeWindow  NSWindow *)window toHeight  int)height toWidth  int)width;
@end
</font>[/code]
Application.m:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
#import <font color = red>"Application.h"</font>
@implementation NSApplication (ApplicationName)
- (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(windowFr ame) - width,NSMaxY(windowFrame) - height,width,height) styleMask:[window styleMask]];
[window setFrame:newWindowFrame display:YES animate:YES];
}
@end
</font>[/code]
Hope this helps!
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Just wondering why you implemented it as a category of NSApplication? Seems a bit silly to me.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: The Land of Beer and Chocolates
Status:
Offline
|
|
Originally posted by Ibson:
<STRONG>Sorry  --here's the full listing:
.....
Hope this helps!</STRONG>
Thanks a lot , it works now , but it has a side-effect : if I resize a window , the window doesn't stay where it was . Instead , it slides to the left . Do you know why ?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: The Land of Beer and Chocolates
Status:
Offline
|
|
Originally posted by Jan Van Boghout:
<STRONG>
Thanks a lot , it works now , but it has a side-effect : if I resize a window , the window doesn't stay where it was . Instead , it slides to the left . Do you know why ?</STRONG>
Sorry , I didn't read your first post completely
I didn't see "(if it doesn't change "NSMinX(windowFrame) - width" to "NSMinX(windowFrame)"
Now I did that and it works like it should , thanks a lot !
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Status:
Offline
|
|
Originally posted by Angus_D:
<STRONG>Just wondering why you implemented it as a category of NSApplication? Seems a bit silly to me.</STRONG>
True, but AppleScript Studio won't access methods that aren't a category of NSApplication. This is one of the major problems I've had using AS-S.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|