Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Enable fullscreen mode in Applescript Studio applications Apps
I looked high and low for a way to create a full screen mode from an Applescript Studio application. I didn't find one, but I did learn enough to create one ... read the rest of the hint for the code snippets.

Add the following two files to your project:

Fullscreen.h:
#import 
#import 
@interface NSApplication (ASKAFullScreen)
- (NSWindow *)beginFullScreen;
- (void)endFullScreen;
@end
Fullscreen.mm:
#import "FullScreen.h"
NSWindow *fsWindow;
@implementation NSApplication (ASKAFullScreen)
- (NSWindow *)beginFullScreen
{   fsWindow = [
      [NSWindow alloc]
      initWithContentRect:[[NSScreen mainScreen] frame]
      styleMask:NSBorderlessWindowMask
      backing:NSBackingStoreBuffered
      defer:NO];
    NSView *fsView=[[NSView alloc] initWithFrame:[fsWindow frame]];
    [fsWindow setContentView:fsView];
    NSImageView *fsImage = [[NSImageView alloc] initWithFrame:[fsView frame]];
    [fsView addSubview:fsImage];
    [fsWindow setBackgroundColor:[NSColor blackColor]];
    [NSMenu setMenuBarVisible:0];
    [fsWindow makeKeyAndOrderFront:fsWindow];
    return fsWindow;
}
- (void)endFullScreen
{   [NSMenu setMenuBarVisible:1];
    [fsWindow close];
}
@end
Then you can use applescript to open and close the fullscreen window:
set theWindow to (call method "beginFullScreen")
call method "endFullScreen"
I hope someone else gets some use out of this example.
    •    
  • Currently 3.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[14,010 views]  

Enable fullscreen mode in Applescript Studio applications | 14 comments | Create New Account
Click here to return to the 'Enable fullscreen mode in Applescript Studio applications' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Enable fullscreen mode in Applescript Studio applications
Authored by: dr_turgeon on Aug 06, '03 12:38:15PM

Now this is a Mac OS X hint!

I haven't tried it yet, but thanks in advance :)



[ Reply to This | # ]
some advice on using this tip
Authored by: kjaleel on Aug 07, '03 05:23:34AM

this is a great hint indeed, I've been searching for a way to do this as well. I'm a bit inexperienced with applescript and osx however, and I hope you could clarify some things for me.

Am i supposed to created a normal Cocoa application in PB and then add these two files to it, build it, and then create an applescript to call the function? I don't know how to do this.

Or can I just add the 2 files to an applescript studio project and add an applescript to the same project that calls the functions? This is what I've tried and it doesn't work. when I run the script, it simply just displays a an empty window and nothing happens.
Do I need to do something special to call the functions?



[ Reply to This | # ]
some advice on using this tip
Authored by: googoo on Aug 07, '03 08:33:40AM

The hint is for AppleScript Studio. You can use the AppleScript call to the method (at the end of the hint) for a menu item, button, etc.

Great hint!

-Mark



[ Reply to This | # ]
Enable fullscreen mode in Applescript Studio applications
Authored by: mistercow on Aug 07, '03 12:14:55PM

That's a good hint, although it applies even to non applescript developers.

By the way, you really should put "[fsWindow setHasShadow: NO];" on a line after "[NSMenu setMenuBarVisible:0];".

This will get rid of the shadow, which is important if the end user has multiple monitors. I have noticed many apps that have full screen windows where I can see a shadow creeping onto my other monitor.



[ Reply to This | # ]
What about smooth resizing in Applescript Studio applications
Authored by: DizzyPenguin on Aug 07, '03 02:04:39PM

Great hint.
Now can anyone else come up with the neat code to resize a window or panel smoothly? Pretty please...

---
--
DizzyPenguin



[ Reply to This | # ]
What about smooth resizing in Applescript Studio applications
Authored by: kitzkikz on Aug 08, '03 02:58:42PM

I don't understand what you mean by 'smooth resizing'? The following seems to work well for me (although it is a bit verbose):

set winsize to (size of window 1)
set winx to (item 1 of winsize)
set winy to (item 2 of winsize)
set size of window 1 to {winx / 2, winy / 2}

The window jumps to the new size immediately. Am I missing the point of your question?



[ Reply to This | # ]
What about smooth resizing in Applescript Studio applications
Authored by: DizzyPenguin on Aug 10, '03 02:03:30PM

By "smooth" I mean the window won't 'jump' to the new size but 'stretch', like the login panel in OSX when you've got the one user name displayed, your press spacebar and the window resizes smoothly to show the password field.

---
DizzyPenguin



[ Reply to This | # ]
Smooth resizing - Snippet
Authored by: DizzyPenguin on Aug 10, '03 02:14:38PM
I got this from the Applescript Studio mailing list:
Put the following lines in your main.m file // Thanks to Jan Van Boghout for this code, from his demo app "SmoothResize" #import "Application.h" @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(windowFrame),NSMaxY(windowFram e) - height,width,height) styleMask:[window styleMask]]; [window setFrame:newWindowFrame display:YES animate:YES]; } @end Next, to call on this, use the following syntax: call method "resizeWindow:toHeight:toWidth:" with parameters {window "theWindow", Y, X}
But there was no indication of the content of the Application.h file. Any help on this would be greatly appreciated.

---
DizzyPenguin

[ Reply to This | # ]

Smooth resizing - Snippet (correction)
Authored by: DizzyPenguin on Aug 10, '03 02:19:50PM

Sorry, the code should be clearer like this:

put the following lines in your main.m file

// Thanks to Jan Van Boghout for this code, from his demo app
"SmoothResize"

#import "Application.h"

@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(windowFrame),NSMaxY(windowFram
e) - height,width,height) styleMask:[window styleMask]];

[window setFrame:newWindowFrame display:YES animate:YES];
}

@end

Next, to call on this, use the following syntax:

call method "resizeWindow:toHeight:toWidth:" with parameters {window
"theWindow", Y, X}

---
DizzyPenguin



[ Reply to This | # ]
Smooth resizing - Sorted
Authored by: DizzyPenguin on Aug 12, '03 05:52:39AM

OK, I got it working (with a little help from my friends!)

---
DizzyPenguin



[ Reply to This | # ]
RE: Smooth resizing - Snippet (correction)
Authored by: samsprograms on Aug 12, '03 04:50:57PM

How do you get this to work with a toolbar? For me it changes the window's size including the toolbar.



[ Reply to This | # ]
Enable fullscreen mode in Applescript Studio applications
Authored by: kitzkikz on Aug 08, '03 02:38:08PM
Oops! The above hint didn't show a couple of important include files (those darn angle brackets):

Fullscreen.h
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h> 
@interface NSApplication (ASKAFullScreen)
- (NSWindow *)beginFullScreen;
- (void)endFullScreen;
@end


[ Reply to This | # ]
Enable fullscreen mode in Applescript Studio applications
Authored by: macnus on Dec 13, '03 12:27:36PM

I can't get it to work, when i use the script: set theWindow to (call method \"beginfullscreen\") it says +[NSScreen mainscreen]: selector not recognized
can anybody help me?



[ Reply to This | # ]
Enable fullscreen mode in Applescript Studio applications
Authored by: loren_ryter on Jul 14, '05 11:32:44AM

Thanks-- I was looking for a way to do this. I have successfully got the methods to work. I can toggle full screen on and off in AS Studio from a menu item. (Btw, here's another hint about <a href="http://bbs.applescript.net/viewtopic.php?id=5460>toggling menu item states</a> ;-)

However, I am apparenlty too ignorant to know what to do with it.

What is "theWindow"? If I use the original line "set theWindow ..." then I just get a black screen. If I use one of my application's own windows:

set window "main" to (call method "beginFullScreen")

Then I get errors... NS Internal Script Error (8).

(Apparently when trying to draw to it.)

In my project (a simple slide show app), window "main" contains an image view.



[ Reply to This | # ]