зеркало из https://github.com/electron/electron.git
Merge pull request #9108 from yuya-oc/add-macos-sheet-events
Add sheet-begin and sheet-end events to macOS BrowserWindow
This commit is contained in:
Коммит
dc8b43901b
|
@ -263,6 +263,14 @@ void Window::OnWindowSwipe(const std::string& direction) {
|
|||
Emit("swipe", direction);
|
||||
}
|
||||
|
||||
void Window::OnWindowSheetBegin() {
|
||||
Emit("sheet-begin");
|
||||
}
|
||||
|
||||
void Window::OnWindowSheetEnd() {
|
||||
Emit("sheet-end");
|
||||
}
|
||||
|
||||
void Window::OnWindowEnterHtmlFullScreen() {
|
||||
Emit("enter-html-full-screen");
|
||||
}
|
||||
|
|
|
@ -79,6 +79,8 @@ class Window : public mate::TrackableObject<Window>,
|
|||
void OnWindowScrollTouchEnd() override;
|
||||
void OnWindowScrollTouchEdge() override;
|
||||
void OnWindowSwipe(const std::string& direction) override;
|
||||
void OnWindowSheetBegin() override;
|
||||
void OnWindowSheetEnd() override;
|
||||
void OnWindowEnterFullScreen() override;
|
||||
void OnWindowLeaveFullScreen() override;
|
||||
void OnWindowEnterHtmlFullScreen() override;
|
||||
|
|
|
@ -554,6 +554,16 @@ void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
|
|||
observer.OnWindowSwipe(direction);
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowSheetBegin() {
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowSheetBegin();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowSheetEnd() {
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowSheetEnd();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowLeaveFullScreen() {
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnWindowLeaveFullScreen();
|
||||
|
|
|
@ -233,6 +233,8 @@ class NativeWindow : public base::SupportsUserData,
|
|||
void NotifyWindowScrollTouchEnd();
|
||||
void NotifyWindowScrollTouchEdge();
|
||||
void NotifyWindowSwipe(const std::string& direction);
|
||||
void NotifyWindowSheetBegin();
|
||||
void NotifyWindowSheetEnd();
|
||||
void NotifyWindowEnterFullScreen();
|
||||
void NotifyWindowLeaveFullScreen();
|
||||
void NotifyWindowEnterHtmlFullScreen();
|
||||
|
|
|
@ -313,6 +313,14 @@ bool ScopedDisableResize::disable_resize_ = false;
|
|||
return rect;
|
||||
}
|
||||
|
||||
- (void)windowWillBeginSheet:(NSNotification *)notification {
|
||||
shell_->NotifyWindowSheetBegin();
|
||||
}
|
||||
|
||||
- (void)windowDidEndSheet:(NSNotification *)notification {
|
||||
shell_->NotifyWindowSheetEnd();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface AtomPreviewItem : NSObject <QLPreviewItem>
|
||||
|
|
|
@ -67,6 +67,8 @@ class NativeWindowObserver {
|
|||
virtual void OnWindowScrollTouchEnd() {}
|
||||
virtual void OnWindowScrollTouchEdge() {}
|
||||
virtual void OnWindowSwipe(const std::string& direction) {}
|
||||
virtual void OnWindowSheetBegin() {}
|
||||
virtual void OnWindowSheetEnd() {}
|
||||
virtual void OnWindowEnterFullScreen() {}
|
||||
virtual void OnWindowLeaveFullScreen() {}
|
||||
virtual void OnWindowEnterHtmlFullScreen() {}
|
||||
|
|
|
@ -498,6 +498,14 @@ Returns:
|
|||
|
||||
Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, `left`.
|
||||
|
||||
#### Event: 'sheet-begin' _macOS_
|
||||
|
||||
Emitted when the window opens a sheet.
|
||||
|
||||
#### Event: 'sheet-end' _macOS_
|
||||
|
||||
Emitted when the window has closed a sheet.
|
||||
|
||||
### Static Methods
|
||||
|
||||
The `BrowserWindow` class has the following static methods:
|
||||
|
|
|
@ -1191,6 +1191,54 @@ describe('BrowserWindow module', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('sheet-begin event', function () {
|
||||
if (process.platform !== 'darwin') {
|
||||
return
|
||||
}
|
||||
|
||||
let sheet = null
|
||||
|
||||
afterEach(function () {
|
||||
return closeWindow(sheet, {assertSingleWindow: false}).then(function () { sheet = null })
|
||||
})
|
||||
|
||||
it('emits when window opens a sheet', function (done) {
|
||||
w.show()
|
||||
w.once('sheet-begin', function () {
|
||||
sheet.close()
|
||||
done()
|
||||
})
|
||||
sheet = new BrowserWindow({
|
||||
modal: true,
|
||||
parent: w
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('sheet-end event', function () {
|
||||
if (process.platform !== 'darwin') {
|
||||
return
|
||||
}
|
||||
|
||||
let sheet = null
|
||||
|
||||
afterEach(function () {
|
||||
return closeWindow(sheet, {assertSingleWindow: false}).then(function () { sheet = null })
|
||||
})
|
||||
|
||||
it('emits when window has closed a sheet', function (done) {
|
||||
w.show()
|
||||
sheet = new BrowserWindow({
|
||||
modal: true,
|
||||
parent: w
|
||||
})
|
||||
w.once('sheet-end', function () {
|
||||
done()
|
||||
})
|
||||
sheet.close()
|
||||
})
|
||||
})
|
||||
|
||||
describe('beginFrameSubscription method', function () {
|
||||
// This test is too slow, only test it on CI.
|
||||
if (!isCI) return
|
||||
|
|
Загрузка…
Ссылка в новой задаче