I’m fine-tuning my interface. If I grab the lower right hand corner of the window and drag, the window can resize to the point where the loer corner is off the screen. If I let go I have no way of re-sizing the window again. Anyone have any code already to stop the window from resizing anymore if the bottom edge of the window hits the bottom edge of the screen?
I am thinking you would need to get the screen resolution somehow and then in the will resize make sure the widow height + the y position of the window is not greater than the screen resolution. How would I get the current height in pixels of the user’s monitor??
Model: iMac Intel
AppleScript: xCode 3.0
Browser: Safari 525.20.1
Operating System: Mac OS X (10.5)
Duh. I finally figured out that if I set my window resizing proportionally to be based on the height, instead of the width, that solves everything since you can’t drag the mouse off the bottom of the screen. My windows are all taller than wide, so you would want to keep it based on width if you had a wide window.
Sometimes it’s simpler than you think…
on became main theObject
set {currentWindowWidth, currentWindowHeight} to size of theObject
set currentWindowProportions to (currentWindowHeight / currentWindowWidth)
end became main
on will resize theObject proposed size proposedSize
set {tmpWidth, tmpHeight} to proposedSize
return {(tmpHeight / currentWindowProportions), tmpHeight}
end will resize
Model: iMacintel
AppleScript: xCode 3.0
Browser: Safari 525.20.1
Operating System: Mac OS X (10.5)
My idea would be to use the “bounds” property of a window. That gives you the outside dimensions. At program launch you could get the size of the user’s screen and thus you have the max bounds that your window can be. Then you just need to check your window’s bounds against the max bounds, and if they’re greater then set the window’s bounds to the max bounds. If you do this in on idle or resized handlers it should always keep any dimension of your window from going past the screen bounds.