Window->Zoom

Anyone have handy code for implementing the Zoom menu?

Does the Zoom menu do the same thing as the green window button on Mac apps?

[quote=20161:@Stephen Dodd]Anyone have handy code for implementing the Zoom menu?

Does the Zoom menu do the same thing as the green window button on Mac apps?[/quote]

It sends performZoom: up the responder chain via -[NSApplication sendAction:to:from:], I believe.

If you use MBS plugins, just create a menu handler for a Window:

self.isZoomedMacMBS = not self.isZoomedMacMBS return true

other than that, for Cocoa, look in macoslib

In code you need to implement the zoom function yourself. I would advise that you use the following declare.

declare sub performZoom lib "Cocoa" selector "performZoom:" ( ref as integer, sender as Ptr ) performZoom( mainWindow.handle, nil )
It matches the same function as clicking on the “Green” button.

Thanks Sam.

So, is there a difference between this declare and just using Window.Maximize?

Yes indeed. With performZoom it will ‘maximize’ the window, but call it again or press the green button and it will return to its original size.

Calling window.maximize and the window will maximize, but a second call won’t return it to its original state, neither will the green button.

I’ve got a feature request (not at computer so can’t look it up) asking for .maximize to use performZoom underneath.

Am I doing something wrong, then? I just put Self.Maximize on a PushButton on a window and the first time I click it, the window maximizes. If I click it again while it is maximized it returns to its original size. Pressing the green button in the title bar after clicking the maximize button the first time also restores it to its original size. (OS X 10.8.4).

hmm… That’s not what I found, which is why I looked into the NS documentation. Maybe I was doing something wrong, I’ll double check.

I’ve got the same results as Paul compiling for Cocoa.

Well I’ll be a monkey’s uncle - I sure as heck don’t know what I was doing then, because sure enough in 2013r2 it works as you’d hope. Sorry for all the noise - cave here I come…

Well, that’s cool. I’ll just put Window.Maximize in the Zoom Menu Event handler then.

The problem is the Zoom menu item on Mac is a toggle. It maximizes and then step back to previous window size if selected again.
Using Window.Maximize is a way with no return.

[quote=20686:@Massimo Valle]The problem is the Zoom menu item on Mac is a toggle. It maximizes and then step back to previous window size if selected again.
Using Window.Maximize is a way with no return.[/quote]
That’s what we are discussing. Window.Maximize is also a toggle.

That’s cool, I never realized this. Perhaps the method name is deceiving…
Window.ToggleMaximize would have been more intuitive.

Thanks Paul!