Add blur method to window ref #4724
This commit is contained in:
parent
377a8eefb2
commit
704b8335aa
4 changed files with 17 additions and 0 deletions
|
@ -294,6 +294,10 @@ void Window::Focus() {
|
||||||
window_->Focus(true);
|
window_->Focus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::Blur() {
|
||||||
|
window_->Focus(false);
|
||||||
|
}
|
||||||
|
|
||||||
bool Window::IsFocused() {
|
bool Window::IsFocused() {
|
||||||
return window_->IsFocused();
|
return window_->IsFocused();
|
||||||
}
|
}
|
||||||
|
@ -688,6 +692,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
.MakeDestroyable()
|
.MakeDestroyable()
|
||||||
.SetMethod("close", &Window::Close)
|
.SetMethod("close", &Window::Close)
|
||||||
.SetMethod("focus", &Window::Focus)
|
.SetMethod("focus", &Window::Focus)
|
||||||
|
.SetMethod("blur", &Window::Blur)
|
||||||
.SetMethod("isFocused", &Window::IsFocused)
|
.SetMethod("isFocused", &Window::IsFocused)
|
||||||
.SetMethod("show", &Window::Show)
|
.SetMethod("show", &Window::Show)
|
||||||
.SetMethod("showInactive", &Window::ShowInactive)
|
.SetMethod("showInactive", &Window::ShowInactive)
|
||||||
|
|
|
@ -83,6 +83,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
// APIs for NativeWindow.
|
// APIs for NativeWindow.
|
||||||
void Close();
|
void Close();
|
||||||
void Focus();
|
void Focus();
|
||||||
|
void Blur();
|
||||||
bool IsFocused();
|
bool IsFocused();
|
||||||
void Show();
|
void Show();
|
||||||
void ShowInactive();
|
void ShowInactive();
|
||||||
|
|
|
@ -397,6 +397,10 @@ the [close event](#event-close).
|
||||||
|
|
||||||
Focus on the window.
|
Focus on the window.
|
||||||
|
|
||||||
|
### `win.blur()`
|
||||||
|
|
||||||
|
Remove focus on the window.
|
||||||
|
|
||||||
### `win.isFocused()`
|
### `win.isFocused()`
|
||||||
|
|
||||||
Returns a boolean, whether the window is focused.
|
Returns a boolean, whether the window is focused.
|
||||||
|
|
|
@ -145,6 +145,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() {
|
describe('BrowserWindow.capturePage(rect, callback)', function() {
|
||||||
it('calls the callback with a Buffer', function(done) {
|
it('calls the callback with a Buffer', function(done) {
|
||||||
w.capturePage({
|
w.capturePage({
|
||||||
|
|
Loading…
Reference in a new issue