Window size

How do I set window size?
I found “setFrame:display:animate:” but don’t know if/how to implement.

Animation would be preferable but not necessary. Thanks for the help!

Don’t know much about ASOC, but this should be close

aWindow's setFrame_display_animate_({0,0,800,600}), true, true)

Hope it works,
ief2

Close – try:

aWindow's setFrame_display_animate_({{0, 0}, {800, 600}}, true, true)

Beautiful! I knew i was on the right track. How do I keep the window to keep its current position on the screen so when it transforms it looks like it’s sitting still?

Thanks to you both!

There’s no simple one-liner. You’ll have to get its existing bounds, and use that to work out the new bounds you require, remembering that that y values work from the bottom of the screen up.

While you can use a list like {{0,0},{100,100}} for bound, you should probably use a record:

set {origin:{x:n, y:m}, |size|:{|width|:n2, height:m2}} to (aWindow's bounds()) as record

That way you can parse it like any AS record – eg:

 x of origin of someBounds
et {origin:{x:n, y:m}, |size|:{|width|:n2, height:m2}} to (mainWin's bounds()) as record

Build fails on this line. It will build without the parenthesis or by adding a comma like:

bounds,{}}

Notice that it changed the parenthesis to curly braces.

Either way, even when it builds successfully, it errors when that line is called.

Without parenthesis, I get

What the heck am I doing wrong?

Ah – my mistake, I was trusting my faulty memory. It’s not bounds, it’s frame:

set {origin:{x:n, y:m}, |size|:{|width|:n2, height:m2}} to (aWindow's frame()) as record

I know this is an old topic but managed to shove it all into one line, it expands from the top left corner.

mainWindow's setFrame_display_animate_({{(x of origin of (mainWindow's frame())), ((y of origin of mainWindow's frame()) - ((newHeight's integerValue())- height of |size| of (mainWindow's frame())))}, {newWidth's integerValue(), newHeight's integerValue()}}, true, true)

AStevensTaylor, hope you like :smiley:

The trouble is that your code is asking mainWindow for its frame three times, rather than just once, so that one line is likely to be slower than doing it in two.

Am I missing something? the window still resizes from bottom left:


set {origin:{x:n, y:m}, |size|:{|width|:n2, height:m2}} to (thisWindow's frame()) as record

thisWindow's setFrame_display_animate_({{x of origin of (thisWindow's frame), y of origin of (thisWindow's frame)}, {408, 100}}, true, true)


Yes:


set {origin:{x:n, y:m}, |size|:{|width|:n2, height:m2}} to (thisWindow's frame()) as record
thisWindow's setFrame_display_animate_({{n, m - m2 + 100}, {408, 100}}, true, true)


Ah, thats easier than I thought. Thank you Shane!