Recent

Author Topic: Hiding the main menu and dock [SOLVED]  (Read 11195 times)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Hiding the main menu and dock [SOLVED]
« on: April 11, 2011, 09:46:45 pm »
I am writing an application that requires a full screen display of images, and am trying to figure out how to hide the main menu and dock. I can make it full screen, but can't hide the menu.

Adding:

  <key>LSUIPresentationMode</key>
  <integer>4</integer>

to my bundle Info.plist correctly does what I want, but the menu and dock remain hidden all the time. I would like to be able to hide them only while the show is in progress.

Does anyone know how to turn LSUIPresentationMode on and off in code?

Any tips appreciated.

Cheers,
Frederick
« Last Edit: June 08, 2011, 06:47:24 pm by Frederick »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)


VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Hiding the main menu and dock
« Reply #2 on: April 11, 2011, 11:06:53 pm »
Thanks jmaebe,

This looks potentially useful, but I am currently using TBGRABitmap to draw into a TImage TCanvas. If I were to try this technique, I presumably have to copy a bitmap to the display. I'm not at all sure how to do that.

I'd prefer their second approach, which is to "create and draw into a borderless window the size of the display". This also seems safer than taking over the display. I'm hoping there is a simple system call to turn on display mode.

Cheers,
Frederick
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Hiding the main menu and dock
« Reply #3 on: April 12, 2011, 12:42:49 am »
You can assign an empty menu.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Hiding the main menu and dock
« Reply #4 on: April 12, 2011, 01:06:33 am »
typo,

An 'empty' menu still shows up as a menu bar with the Apple system item and the application name, as well as all the other icons on the right. Am I not understanding  your suggestion?

Is there some way to assign a nil menu in code?

Thanks,
Frederick
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Hiding the main menu and dock
« Reply #5 on: April 12, 2011, 01:19:30 am »
On my Windows system, assigning Form1.Menu as nil does not even make the previous menu to disappear, but it does not repaint anymore.
« Last Edit: April 12, 2011, 01:23:59 am by typo »

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Hiding the main menu and dock
« Reply #6 on: April 12, 2011, 02:04:11 am »
On my Windows system, assigning Form1.Menu as nil does not even make the previous menu to disappear, but it does not repaint anymore.

I see what you mean. I just gave that a try, but the default menu still shows up. You can select items from it, but it gives an access error. A good idea, but no go on OS X.

Thanks,
Frederick
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Hiding the main menu and dock
« Reply #7 on: June 08, 2011, 05:06:02 pm »
In poking around the web I found the OS X system calls required to do this here:

http://developer.apple.com/library/mac/#technotes/tn2002/tn2062.html

The call is this:

OSStatus SetSystemUIMode(
            SystemUIMode inMode,
            SystemUIOptions inOptions);

My knowledge of implementing system calls in Lazarus is nil, but it seems like it should not be too difficult. Can anyone point me in the right direction?

Cheers,
Frederick
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Hiding the main menu and dock
« Reply #8 on: June 08, 2011, 05:12:22 pm »
The call is this:

OSStatus SetSystemUIMode(
            SystemUIMode inMode,
            SystemUIOptions inOptions);

My knowledge of implementing system calls in Lazarus is nil, but it seems like it should not be too difficult. Can anyone point me in the right direction?

It's available via the FPC MacOSAll unit. An alternative set of calls to use is BeginFullScreen() and EndFullScreen().

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Hiding the main menu and dock
« Reply #9 on: June 08, 2011, 06:46:14 pm »
It's available via the FPC MacOSAll unit. An alternative set of calls to use is BeginFullScreen() and EndFullScreen().

Beautiful!!! This does just what I need:

Code: [Select]
if startFullScreen then
  SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar)
else
   SetSystemUIMode(kUIModeNormal, 0);

Thank you so much jmaebe.  :D

Cheers,
Frederick
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

 

TinyPortal © 2005-2018