зеркало из https://github.com/electron/electron.git
feat: implement `will-move` event on macOS (#19641)
This commit is contained in:
Родитель
cd1b15a155
Коммит
145b4fae94
|
@ -516,14 +516,14 @@ Note that this is only emitted when the window is being resized manually. Resizi
|
|||
|
||||
Emitted after the window has been resized.
|
||||
|
||||
#### Event: 'will-move' _Windows_
|
||||
#### Event: 'will-move' _macOS_ _Windows_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `newBounds` [`Rectangle`](structures/rectangle.md) - Location the window is being moved to.
|
||||
|
||||
Emitted before the window is moved. Calling `event.preventDefault()` will prevent the window from being moved.
|
||||
Emitted before the window is moved. On Windows, calling `event.preventDefault()` will prevent the window from being moved.
|
||||
|
||||
Note that this is only emitted when the window is being resized manually. Resizing the window with `setBounds`/`setSize` will not emit this event.
|
||||
|
||||
|
|
|
@ -138,6 +138,18 @@ using TitleBarStyle = electron::NativeWindowMac::TitleBarStyle;
|
|||
shell_->NotifyWindowResize();
|
||||
}
|
||||
|
||||
- (void)windowWillMove:(NSNotification*)notification {
|
||||
NSWindow* window = [notification object];
|
||||
NSSize size = [[window contentView] frame].size;
|
||||
NSRect new_bounds = NSMakeRect(window.frame.origin.x, window.frame.origin.y,
|
||||
size.width, size.height);
|
||||
bool prevent_default = false;
|
||||
|
||||
// prevent_default has no effect
|
||||
shell_->NotifyWindowWillMove(gfx::ScreenRectFromNSRect(new_bounds),
|
||||
&prevent_default);
|
||||
}
|
||||
|
||||
- (void)windowDidMove:(NSNotification*)notification {
|
||||
[super windowDidMove:notification];
|
||||
// TODO(zcbenz): Remove the alias after figuring out a proper
|
||||
|
|
Загрузка…
Ссылка в новой задаче