Merge pull request #11832 from electron/enable-window

Add API to enable/disable a window
This commit is contained in:
shelley vohr 2018-02-06 14:14:45 -05:00 committed by GitHub
commit 64f509ea7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 1 deletions

View file

@ -393,6 +393,10 @@ bool Window::IsEnabled() {
return window_->IsEnabled();
}
void Window::SetEnabled(bool enable) {
window_->SetEnabled(enable);
}
void Window::Maximize() {
window_->Maximize();
}
@ -1008,6 +1012,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.SetMethod("hide", &Window::Hide)
.SetMethod("isVisible", &Window::IsVisible)
.SetMethod("isEnabled", &Window::IsEnabled)
.SetMethod("setEnabled", & Window::SetEnabled)
.SetMethod("maximize", &Window::Maximize)
.SetMethod("unmaximize", &Window::Unmaximize)
.SetMethod("isMaximized", &Window::IsMaximized)

View file

@ -112,6 +112,7 @@ class Window : public mate::TrackableObject<Window>,
void Hide();
bool IsVisible();
bool IsEnabled();
void SetEnabled(bool enable);
void Maximize();
void Unmaximize();
bool IsMaximized();

View file

@ -80,6 +80,7 @@ class NativeWindow : public base::SupportsUserData,
virtual void Hide() = 0;
virtual bool IsVisible() = 0;
virtual bool IsEnabled() = 0;
virtual void SetEnabled(bool enable) = 0;
virtual void Maximize() = 0;
virtual void Unmaximize() = 0;
virtual bool IsMaximized() = 0;

View file

@ -38,6 +38,7 @@ class NativeWindowMac : public NativeWindow,
void Hide() override;
bool IsVisible() override;
bool IsEnabled() override;
void SetEnabled(bool enable) override;
void Maximize() override;
void Unmaximize() override;
bool IsMaximized() override;

View file

@ -1135,6 +1135,17 @@ bool NativeWindowMac::IsEnabled() {
return [window_ attachedSheet] == nil;
}
void NativeWindowMac::SetEnabled(bool enable) {
if (enable) {
[window_ beginSheet: window_ completionHandler:^(NSModalResponse returnCode) {
NSLog(@"modal enabled");
return;
}];
} else {
[window_ endSheet: [window_ attachedSheet]];
}
}
void NativeWindowMac::Maximize() {
if (IsMaximized())
return;

View file

@ -132,7 +132,7 @@ class NativeWindowViews : public NativeWindow,
void SetIcon(const gfx::ImageSkia& icon);
#endif
void SetEnabled(bool enable);
void SetEnabled(bool enable) override;
views::Widget* widget() const { return window_.get(); }

View file

@ -847,6 +847,12 @@ the supplied bounds.
Returns [`Rectangle`](structures/rectangle.md)
#### `win.setEnabled(enable)`
* `enable` Boolean
Disable or enable the window.
#### `win.setSize(width, height[, animate])`
* `width` Integer