From: Max Beatty Date: Fri, 11 Mar 2016 05:45:51 +0000 (-0800) Subject: Add blur method to window ref #4724 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=704b8335aafad69c78d5dc75528133f3b89f36fe;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Add blur method to window ref #4724 --- diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index ea1d95b..fb5f3ed 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -294,6 +294,10 @@ void Window::Focus() { window_->Focus(true); } +void Window::Blur() { + window_->Focus(false); +} + bool Window::IsFocused() { return window_->IsFocused(); } @@ -688,6 +692,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) diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 641124f..c984090 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -83,6 +83,7 @@ class Window : public mate::TrackableObject, // APIs for NativeWindow. void Close(); void Focus(); + void Blur(); bool IsFocused(); void Show(); void ShowInactive(); diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 6e1bc99..b214596 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -397,6 +397,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. diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 731ae1c..3474a85 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -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() { it('calls the callback with a Buffer', function(done) { w.capturePage({