Merge pull request #4751 from maxbeatty/window-blur

Add blur method to window
This commit is contained in:
Cheng Zhao 2016-03-11 19:15:51 +09:00
commit 03ec5ced05
4 changed files with 17 additions and 0 deletions

View file

@ -302,6 +302,10 @@ void Window::Focus() {
window_->Focus(true);
}
void Window::Blur() {
window_->Focus(false);
}
bool Window::IsFocused() {
return window_->IsFocused();
}
@ -696,6 +700,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.MakeDestroyable()
.SetMethod("close", &Window::Close)
.SetMethod("focus", &Window::Focus)
.SetMethod("blur", &Window::Blur)
.SetMethod("isFocused", &Window::IsFocused)
.SetMethod("show", &Window::Show)
.SetMethod("showInactive", &Window::ShowInactive)

View file

@ -85,6 +85,7 @@ class Window : public mate::TrackableObject<Window>,
// APIs for NativeWindow.
void Close();
void Focus();
void Blur();
bool IsFocused();
void Show();
void ShowInactive();

View file

@ -405,6 +405,10 @@ the [close event](#event-close).
Focus on the window.
### `win.blur()`
Remove focus on the window.
### `win.isFocused()`
Returns a boolean, whether the window is focused.

View file

@ -186,6 +186,13 @@ describe('browser-window module', function() {
});
});
describe('BrowserWindow.blur()', function() {
it('removes focus from window', function() {
w.blur();
assert(!w.isFocused());
});
});
describe('BrowserWindow.capturePage(rect, callback)', function() {
it('calls the callback with a Buffer', function(done) {
w.capturePage({