Cocoa Internals/Dialogs

From Lazarus wiki
Jump to navigationJump to search

Common Considerations

Modality

Neither of the Cocoa dialogs (OpenFile, SaveFile, Font or Color) are modal!

Meaning that one can open a dialog and keep using the other application windows and the application menu.

This doesn't work well, if the LCL design, where each dialog is opened by Execute method, which doesn't return until the modal dialog is closed.

For this particular reason, Cocoa WS does the following:

  • every dialog is called as the application modal window (preventing other windows of the application from getting any user input)
  • the application menu is disabled, until the dialog is closed
  • where applicable add "Ok" and "Cancel" buttons are added to dialogs. Indicating a user that the dialog can be closed in order to make the selection.

No restoration

Starting with macOS 10.7 Cocoa will attempt to restore the Application windows between Launches.

It's a nice user feature, which conflicts with LCL. Since LCL adds custom controls to a dialog, and the restoration requires a special "restorationClass" to be provided.

Instead of restoring dialogs, CocoaWS explicitly forbids the restoration of them.

Class Override

Unlike NSApplication, dialog classes cannot be overwritten in the following manner:

 TCocoaColorPanel.sharedPanel

Doing that will cause problems using class methods of the sharedPanel (and likely something else)

See Also