Recent

Author Topic: Is it possible to replace the Full Screen button with the Maximized button?  (Read 1507 times)

ling

  • New Member
  • *
  • Posts: 14
I don't want my project enter full screen mode, is it possible to replace the Full Screen button with the Maximized button?

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 727
  • Professional amateur ;-P
Hey Ling,

I don't want my project enter full screen mode, is it possible to replace the Full Screen button with the Maximized button?

What do you mean by Full Screen button? I know only of Maximize, Minimize and Close(x).
Have you set your Form's border style to bsNone?

Cheers,
Gus
Lazarus 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.04 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.04 64b Dark Theme
http://github.com/gcarreno

lucamar

  • Hero Member
  • *****
  • Posts: 4219
What do you mean by Full Screen button?

It's probably some Mac OS thing, I guess ...
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 727
  • Professional amateur ;-P
Hey Lucamar,

It's probably some Mac OS thing, I guess ...

Arghhh, I always forget about those guys/gals. Thanks for reminding me ;)

And if it's the case, I'm out of ideas for this one :)

Cheers,
Gus
Lazarus 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.04 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.04 64b Dark Theme
http://github.com/gcarreno

ling

  • New Member
  • *
  • Posts: 14
Sorry, I didn't make my question clear. Yes, I'm working on macOS.

Hansaplast

  • Hero Member
  • *****
  • Posts: 612
  • Tweaking4All.com
    • Tweaking4All
I'm not an expert, but I was curious if I could find a soilution (I do not like how Apple implemented this either).
The example below worked for me. I based some of the code on this example.
The maximize button will now be the classical maximize button (and not the "full screen" button).



Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3.  
  4. {$mode objfpc}{$H+}
  5. {$modeswitch objectivec1}
  6.  
  7.  
  8. interface
  9.  
  10.  
  11. uses
  12.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, CocoaAll;
  13.  
  14.  
  15. type
  16.  
  17.  
  18.   { TForm1 }
  19.  
  20.  
  21.   TForm1 = class(TForm)
  22.     procedure FormCreate(Sender: TObject);
  23.   private
  24.  
  25.  
  26.   public
  27.  
  28.  
  29.   end;
  30.  
  31.  
  32. var
  33.   Form1: TForm1;
  34.  
  35.  
  36. implementation
  37.  
  38.  
  39. {$R *.lfm}
  40.  
  41.  
  42. { TForm1 }
  43.  
  44.  
  45. procedure TForm1.FormCreate(Sender: TObject);
  46. var
  47.   theWindow: NSWindow;
  48. begin
  49.   theWindow := NSView(Form1.Handle).window;      
  50.   theWindow.setCollectionBehavior(theWindow.collectionBehavior or NSWindowCollectionBehaviorFullScreenAuxiliary);
  51. end;
  52.  
  53.  
  54. end.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1590
  • Former Delphi 1-7, 10.2 user
For the uninitiated:

Clicking the Green Dot takes the application full screen (ie obliterates the menu bar and the dock and uses the FULL screen real estate).

Double-clicking on the title bar of an application maximizes it provided System Preferences -> Dock "Double-click a window's title bar to minimize" is unchecked =OR= holding down the Option key and clicking the Green Dot (ie it constrains the application between the menu bar and the dock).

I really doubt that Apple would sanction messing with its standard GUI design (aka human interface guidelines).

« Last Edit: April 13, 2021, 01:53:15 pm by trev »
Lazarus 2.3 2021-08-10 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.3 r65500 FPC 3.3.1 r49634 macOS 11.5.2 aarch64 Xcode 12.5.1
Lazarus 2.3 2021-08-11 FPC 3.2.2 FreeBSD 13.0 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

Hansaplast

  • Hero Member
  • *****
  • Posts: 612
  • Tweaking4All.com
    • Tweaking4All
I agree with you Trev ... however, since NSWindowCollectionBehaviorFullScreenAuxiliary is documented in the Apple documentation (with a very confusing description), I'd carefully assume this to be acceptable to use ... (although I do agree that Apple can have some special considerations at times)

madref

  • Hero Member
  • *****
  • Posts: 861
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
If you want to prevent the form/program to go to full screen then set the properties correctly.
Set the BorderStyle to bsSingle and set the BorderIcons biHelp, biMaximize & biMinimize to False. BUT biSystemMenu MUST BE TRUE otherwise you can not close your form if there is no exit button or so.


See attachment
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus Trunc.git [2.3.0 Rev. 65550] / FPC Trunc.git [3.3.1]
Mac OS X Big Sur

ling

  • New Member
  • *
  • Posts: 14
@Hansaplast Thanks, there is no setCollectionBehavior property in the NSWindow in my environment, I'm using fpc 3.2.0.
@madref I've tried it, the Full Screen button is still there.
@trev I agree with you, my application's UI flow probably doesn't fit Apple design principle, so when the form enters full screen it is not user-friendly.

I have several forms in my application:

Main Form
Editor Form A, B, C ...

The Main Form shows data list, user can open Editor Form to edit data, and they would open multiple Editor Form to do cross check. If the form enters full screen mode, switching between forms becomes difficult to use, that is why I want to replace Full Screen Button with Maximized Button.

I found an alternative way:
If form's PopupParent is set, the border icon will be Zoom (Maximized) not Full Screen.
I set Editor Form's PopupParent to Main Form on form activate, remove PopupParent on form deactivate to prevent Editor Form blocks Main Form.

Hansaplast

  • Hero Member
  • *****
  • Posts: 612
  • Tweaking4All.com
    • Tweaking4All

Thanks, there is no setCollectionBehavior property in the NSWindow in my environment, I'm using fpc 3.2.0.


Sorry, I forgot about that ... I'm using Lazarus 2.1.0 r64688 FPC 3.3.1 x86_64-darwin-cocoa
Not sure if the following is relevant or useful ...


setCollectionBehavior is declared (in the version I'm running) in NSWindow.inc line 414 as
( fpcsrc/packages/cocoaint/src/appkit/NSWindow.inc )


Code: Pascal  [Select][+][-]
  1. procedure setCollectionBehavior(newValue: NSWindowCollectionBehavior); message 'setCollectionBehavior:';


and NSWindowCollectionBehaviorFullScreenAuxiliary (line 64 of NSWindow.inc) as


Code: Pascal  [Select][+][-]
  1. NSWindowCollectionBehaviorFullScreenAuxiliary = 1 shl 8 { available in 10_7 };

 

TinyPortal © 2005-2018