Skip to content

Commit 7ff98b1

Browse files
Merge pull request #54 from macosui/issue_44
Issue #44
2 parents 812803c + 41468a5 commit 7ff98b1

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.6.1
2+
3+
- Add instructions on how to setup macos_window_utils for macOS Monterey and earlier versions.
4+
15
## 1.6.0
26

37
- Add support for a blocking toolbar, that is, a special kind of toolbar that blocks double clicks from the user and allows for UI elements to be placed inside a blocked area (thanks to @cbenhagen and @Andre-lbc).

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,58 @@ options.applyAsFullScreenPresentationOptions();
234234

235235
**Note:** `NSAppPresentationOptions` uses the `NSWindow`'s delegate to change the window's fullscreen presentation options. Therefore, `enableWindowDelegate` needs to be set to `true` in your `WindowManipulator.initialize` call for it to work.
236236

237+
## Older macOS versions
238+
239+
If you’re targeting older macOS versions (Monterey and earlier), it is necessary to perform the following steps to make the macos_window_utils plugin work correctly:
240+
241+
Open the `macos/Runner.xcworkspace` folder of your project using Xcode, press ⇧ + ⌘ + O and search for `MainFlutterWindow.swift`.
242+
243+
Insert `import macos_window_utils` at the top of the file.
244+
Then, replace the code above the `super.awakeFromNib()`-line with the following code:
245+
246+
```swift
247+
let windowFrame = self.frame
248+
let macOSWindowUtilsViewController = MacOSWindowUtilsViewController()
249+
self.contentViewController = macOSWindowUtilsViewController
250+
self.setFrame(windowFrame, display: true)
251+
252+
/* Initialize the macos_window_utils plugin */
253+
MainFlutterWindowManipulator.start(mainFlutterWindow: self)
254+
255+
RegisterGeneratedPlugins(registry: macOSWindowUtilsViewController.flutterViewController)
256+
```
257+
258+
Assuming you're starting with the default configuration, the finished code should look something like this:
259+
260+
```diff
261+
import Cocoa
262+
import FlutterMacOS
263+
+import macos_window_utils
264+
265+
class MainFlutterWindow: NSWindow {
266+
override func awakeFromNib() {
267+
- let flutterViewController = FlutterViewController.init()
268+
- let windowFrame = self.frame
269+
- self.contentViewController = flutterViewController
270+
- self.setFrame(windowFrame, display: true)
271+
272+
- RegisterGeneratedPlugins(registry: flutterViewController)
273+
274+
+ let windowFrame = self.frame
275+
+ let macOSWindowUtilsViewController = MacOSWindowUtilsViewController()
276+
+ self.contentViewController = macOSWindowUtilsViewController
277+
+ self.setFrame(windowFrame, display: true)
278+
279+
+ /* Initialize the macos_window_utils plugin */
280+
+ MainFlutterWindowManipulator.start(mainFlutterWindow: self)
281+
282+
+ RegisterGeneratedPlugins(registry: macOSWindowUtilsViewController.flutterViewController)
283+
284+
super.awakeFromNib()
285+
}
286+
}
287+
```
288+
237289
## License
238290

239291
MIT License

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: macos_window_utils
22
description:
33
macos_window_utils is a Flutter package that provides a set of methods for
44
modifying the NSWindow of a Flutter application on macOS.
5-
version: 1.6.0
5+
version: 1.6.1
66
repository: https://github.com/Adrian-Samoticha/macos_window_utils.dart
77

88
environment:

0 commit comments

Comments
 (0)