You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,51 @@
1
+
## 1.1.0
2
+
- Add an abstract `NSWindowDelegate` that can be used to listen to events provided by [NSWindowDelegate](https://developer.apple.com/documentation/appkit/nswindowdelegate) such as window resizing, moving, exposing, and minimizing. The following methods are currently supported:
3
+
- Managing Sheets
4
+
-`windowWillBeginSheet`
5
+
-`windowDidEndSheet`
6
+
- Sizing Windows
7
+
-`windowWillResize`
8
+
-`windowDidResize`
9
+
-`windowWillStartLiveResize`
10
+
-`windowDidEndLiveResize`
11
+
- Minimizing Windows
12
+
-`windowWillMiniaturize`
13
+
-`windowDidMiniaturize`
14
+
-`windowDidDeminiaturize`
15
+
- Zooming Window
16
+
-`windowWillUseStandardFrame`
17
+
-`windowShouldZoom`
18
+
- Managing Full-Screen Presentation
19
+
-`windowWillEnterFullScreen`
20
+
-`windowDidEnterFullScreen`
21
+
-`windowWillExitFullScreen`
22
+
-`windowDidExitFullScreen`
23
+
- Moving Windows
24
+
-`windowWillMove`
25
+
-`windowDidMove`
26
+
-`windowDidChangeScreen`
27
+
-`windowDidChangeScreenProfile`
28
+
-`windowDidChangeBackingProperties`
29
+
- Closing Windows
30
+
-`windowShouldClose`
31
+
-`windowWillClose`
32
+
- Managing Key Status
33
+
-`windowDidBecomeKey`
34
+
-`windowDidResignKey`
35
+
- Managing Main Status
36
+
-`windowDidBecomeMain`
37
+
-`windowDidResignMain`
38
+
- Exposing Windows
39
+
-`windowDidExpose`
40
+
- Managing Occlusion State
41
+
-`windowDidChangeOcclusionState`
42
+
- Managing Presentation in Version Browsers
43
+
-`windowWillEnterVersionBrowser`
44
+
-`windowDidEnterVersionBrowser`
45
+
-`windowWillExitVersionBrowser`
46
+
-`windowDidExitVersionBrowser`
47
+
- Add an `NSAppPresentationOptions` class that allows the window's fullscreen presentation options to be modified.
Copy file name to clipboardExpand all lines: README.md
+126-1Lines changed: 126 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ and the Flutter guide for
15
15
16
16
## Features
17
17
18
-
**macos_window_utils**offers, among other things, the following features:
18
+
**macos_window_utils**provides, among other things, the following features:
19
19
20
20
+ Methods to set the application window's material.
21
21
+ Methods to enter/exit fullscreen mode or (un)zoom the window.
@@ -33,6 +33,8 @@ and the Flutter guide for
33
33
+ Methods and widgets to add, remove, and modify visual effect subviews.
34
34
+ Methods to set the window's level as well as reorder the window within its level.
35
35
+ Methods to modify the window's style mask.
36
+
+ An abstract `NSWindowDelegate` class that can be used detect `NSWindow` events, such as window resizing, moving, exposing, and minimizing.
37
+
+ An `NSAppPresentationOptions` class that allows modifications to the window's fullscreen presentation options.
36
38
37
39
Additionally, the package ships with an example project that showcases the plugin's features via an intuitive searchable user interface:
38
40
@@ -152,6 +154,129 @@ Future<void> main() async {
152
154
153
155
Afterwards, call any method of the `WindowManipulator` class to manipulate your application's window.
154
156
157
+
### Using `NSWindowDelegate`
158
+
159
+
`NSWindowDelegate` can be used to listen to `NSWindow` events, such as window resizing, moving, exposing, and minimizing. To use it, first make sure that `enableWindowDelegate` is set to `true` in your `WindowManipulator.initialize` call:
160
+
161
+
```dart
162
+
Future<void> main() async {
163
+
WidgetsFlutterBinding.ensureInitialized();
164
+
165
+
// By default, enableWindowDelegate is set to false to ensure compatibility
166
+
// with other plugins. Set it to true if you wish to use NSWindowDelegate.
This class overrides the `NSWindowDelegate`'s `windowDidEnterFullScreen` method in order to respond to it.
186
+
187
+
The following methods are currently supported by `NSWindowDelegate`:
188
+
<details>
189
+
<summary>Supported methods</summary>
190
+
191
+
- Managing Sheets
192
+
-`windowWillBeginSheet`
193
+
-`windowDidEndSheet`
194
+
- Sizing Windows
195
+
-`windowWillResize`
196
+
-`windowDidResize`
197
+
-`windowWillStartLiveResize`
198
+
-`windowDidEndLiveResize`
199
+
- Minimizing Windows
200
+
-`windowWillMiniaturize`
201
+
-`windowDidMiniaturize`
202
+
-`windowDidDeminiaturize`
203
+
- Zooming Window
204
+
-`windowWillUseStandardFrame`
205
+
-`windowShouldZoom`
206
+
- Managing Full-Screen Presentation
207
+
-`windowWillEnterFullScreen`
208
+
-`windowDidEnterFullScreen`
209
+
-`windowWillExitFullScreen`
210
+
-`windowDidExitFullScreen`
211
+
- Moving Windows
212
+
-`windowWillMove`
213
+
-`windowDidMove`
214
+
-`windowDidChangeScreen`
215
+
-`windowDidChangeScreenProfile`
216
+
-`windowDidChangeBackingProperties`
217
+
- Closing Windows
218
+
-`windowShouldClose`
219
+
-`windowWillClose`
220
+
- Managing Key Status
221
+
-`windowDidBecomeKey`
222
+
-`windowDidResignKey`
223
+
- Managing Main Status
224
+
-`windowDidBecomeMain`
225
+
-`windowDidResignMain`
226
+
- Exposing Windows
227
+
-`windowDidExpose`
228
+
- Managing Occlusion State
229
+
-`windowDidChangeOcclusionState`
230
+
- Managing Presentation in Version Browsers
231
+
-`windowWillEnterVersionBrowser`
232
+
-`windowDidEnterVersionBrowser`
233
+
-`windowWillExitVersionBrowser`
234
+
-`windowDidExitVersionBrowser`
235
+
236
+
</details>
237
+
238
+
<br>
239
+
240
+
Then, add an instance of it via the `WindowManipulator.addNSWindowDelegate` method:
241
+
242
+
```dart
243
+
final delegate = _MyDelegate();
244
+
final handle = WindowManipulator.addNSWindowDelegate(delegate);
245
+
```
246
+
247
+
`WindowManipulator.addNSWindowDelegate` returns a `NSWindowDelegateHandle` which can be used to remove this `NSWindowDelegate` again later:
248
+
249
+
```dart
250
+
handle.removeFromHandler();
251
+
```
252
+
253
+
### Using `NSAppPresentationOptions`
254
+
255
+
Say we would like to automatically hide the toolbar when the window is in fullscreen mode. Using `NSAppPresentationOptions` this can be done as follows:
256
+
257
+
```dart
258
+
// Create NSAppPresentationOptions instance.
259
+
final options = NSAppPresentationOptions.from({
260
+
// fullScreen needs to be present as a fullscreen presentation option at all
261
+
// times.
262
+
NSAppPresentationOption.fullScreen,
263
+
264
+
// Hide the toolbar automatically in fullscreen mode.
265
+
NSAppPresentationOption.autoHideToolbar,
266
+
267
+
// autoHideToolbar must be accompanied by autoHideMenuBar.
268
+
NSAppPresentationOption.autoHideMenuBar,
269
+
270
+
// autoHideMenuBar must be accompanied by either autoHideDock or hideDock.
271
+
NSAppPresentationOption.autoHideDock,
272
+
});
273
+
274
+
// Apply the options as fullscreen presentation options.
275
+
options.applyAsFullScreenPresentationOptions();
276
+
```
277
+
278
+
**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.
0 commit comments