How can I hide the dock and menubar in my fullscreen game? - macos

I'm writing a game that will run in a fullscreen window. I'm using Xojo to code it (therefore any boolean window properties that might be availble in Xcode / Interface Builder are not an option).
Is there a plist key/value I can set in my app that will hide the application menubar and the dock when my window is set to full screen?
Needs to work on Yosemite.

Get the macoslib
It contains extensions for NSWindow that can do this. Just search the project for "fullscreen".
There is also a demo. If you run the project, open the menu bar: Examples -> Cocoa -> NSWindow. That window has a "Toggle Fullscreen" button for testing.

Here is what you need to place in the window Open event :
self.LiveResize = False
self.MenuBarVisible = false
self.FullScreen = true
First line turns off animation,
Second line turns off UI elements (dock and menu bar),
Third line makes the window full screen

Related

Use non-native fullscreen window mode in PhpStorm on macOS

How can I configure PhpStorm to use the "non-native" fullscreen mode? I'd like PhpStorm to be fullscreen (without the macOS top menu bar, etc), in the same window (without creating a new window that I have to scroll between).
The terminal for macOS iTerm2 have this setting. You can choose to remove the tick from "Native full screen windows". When this tick is removed, the fullscreen mode will simply take out all space in the window, without creating a new separate window.
Native fullscreen example
Notice how a new separate "window" is created called "PhpStorm"
Non-native fullscreen example
Notice how theres still one window called "Desktop". The iTerm window fills out the whole screen though.
the only way you can do it at the moment is by adjusting the dock in mac to hide menu automatically and then spread the editor to wider and higher setting
click right on the dock in mac and goto settings and hide menu works for me
i am suffering from same issue lol after i saw iterm2 :P

How to enable auto generation of Window MenuItems (e.g. Tile Window to Left/Right of Screen and Open file with checkmark) in macOS menubar

I am currently creating a macOS menubar for an app without using any interface builder (no XIB/NIB files), just pure code. However I was expecting some items to be auto-generated during the start-up of the app. Items like "Start Dictation", "Emoji & Symbols" under Edit menu were existing as well as the "Enter Full Screen" menu item under the View Menu. But when it comes to Window Menu nothing was automatically generated, only the menu items I've set in the code. Do I have to enable some flags or options when instantiating a Window NSMenu so it automatically generates those items? I am new to macOS development so I feel like I am kind of lost. Thanks in advance.
The Window and Help menus are a little special in that they have their own NSApplication properties, so you will need to set them to your menus so that the system will know what they are.
For example, if you just create a window menu and add it to the main, all you will get are the items that you have provided. If you also set it as the application’s windowsMenu, in addition you will get all the stuff for moving, tab support, etc.
Setting NSApp’s helpMenu is similar, where a Spotlight menu item is added to the menu.

Cocoa: add/show NSBorderlessWindowMask window in window list

I've created a custom NSWindow which is borderless (Using NSBorderlessWindowMask style mask)
I want the window to be listed on the Window Menu (the list of windows shown when you right click on the app icon on the tray)
Note: Titled window with borders is automagically added to this list.
Do you know a way to solve this ?
Is it NSApp related thing ?
OK, i found a way to add window to the window menu manually using NSApp.
[NSApp addWindowsItem:window title:[window title] filename:NO];

Mac OS X Dock: How to programmatically maximize my application with the application's main icon, and not the minimized icon?

According to Mac Dock documentation: "The Dock keeps applications on its left side, while Stacks and minimized windows are kept on its right. If you look closely, you'll see a vertical separator line that separates them."
Meaning, once the application is minimized, you have a NEW dock icon in the right side, and you need to click on it in order to maximize your application.
However, applications like Chrome and Finder behave differently: if you click on the the LEFT icon (the "main" application's icon), it will also maximize the application!
I have created my own mac application, and I'd like to make it behave like Chrome: meaning once it is minimized, if you click on either the left or right dock icons, it will maximize. How can I do that programmatically?
[I am attaching a dock screenshot. You can see both Chrome "main" icon and "minimized" icon next to it. Both icons will respond and will maximize the window.
However other applications (like TextEdit, and also the one I programmed in XCode): only the minimized icon maximizes them. The "main" icon does nothing.]
How can I make both icons maximize my application programmatically?
Thanks a million!
Nili
Need to implement applicationShouldHandleReopen in order to open minimized windows from the "main" icon
- (BOOL)applicationShouldHandleReopen:(NSApplication *) __unused theApplication hasVisibleWindows:(BOOL)flag
{
if (!flag){
[[self window] makeKeyAndOrderFront:self];
}
return YES;
}
Clicking on the Dock icon calls:
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
Reopen your windows in this message handler.
It is send to the Application Delegate and is part of the NSApplicationDelegate protocol.

Hiding NSMenu while the dock remains active

I want my app to show his menu on launch only if the user didn't open a file. Now I can't seem to make it work. Hiding the menu makes the dock and the status bar invisible. I want them to still be there, but not with my own menu (e.g. if you open a file from finder, the finder menu is still visible, but my app opens a window that handles the file, and quits if the user cancels or on completion).
I probably didn't explain it well enough, but here's what I did to solve it :
Add this line to the plist of my app (this produces an app without dock icon or menu), the dock and the menu bar will still be there, but won't be changed by the app :
LSUIElement
(And set the checkbox to true).
This makes your app UI-only (it doesn't show his NSMenu nor does it add an icon to the dock, but just shows your GUI.

Resources