Add app.focus API.
This commit is contained in:
parent
4133fc28d9
commit
9ea1f9956e
4 changed files with 18 additions and 0 deletions
|
@ -79,6 +79,15 @@ v8::Handle<v8::Value> App::Terminate(const v8::Arguments &args) {
|
||||||
return v8::Undefined();
|
return v8::Undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
v8::Handle<v8::Value> App::Focus(const v8::Arguments &args) {
|
||||||
|
v8::HandleScope scope;
|
||||||
|
|
||||||
|
Browser::Get()->Focus();
|
||||||
|
|
||||||
|
return v8::Undefined();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
|
v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
|
@ -122,6 +131,7 @@ void App::Initialize(v8::Handle<v8::Object> target) {
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "quit", Quit);
|
NODE_SET_PROTOTYPE_METHOD(t, "quit", Quit);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "exit", Exit);
|
NODE_SET_PROTOTYPE_METHOD(t, "exit", Exit);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "terminate", Terminate);
|
NODE_SET_PROTOTYPE_METHOD(t, "terminate", Terminate);
|
||||||
|
NODE_SET_PROTOTYPE_METHOD(t, "focus", Focus);
|
||||||
|
|
||||||
target->Set(v8::String::NewSymbol("Application"), t->GetFunction());
|
target->Set(v8::String::NewSymbol("Application"), t->GetFunction());
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ class App : public EventEmitter,
|
||||||
static v8::Handle<v8::Value> Quit(const v8::Arguments &args);
|
static v8::Handle<v8::Value> Quit(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> Exit(const v8::Arguments &args);
|
static v8::Handle<v8::Value> Exit(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> Terminate(const v8::Arguments &args);
|
static v8::Handle<v8::Value> Terminate(const v8::Arguments &args);
|
||||||
|
static v8::Handle<v8::Value> Focus(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> AppendSwitch(const v8::Arguments &args);
|
static v8::Handle<v8::Value> AppendSwitch(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> AppendArgument(const v8::Arguments &args);
|
static v8::Handle<v8::Value> AppendArgument(const v8::Arguments &args);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ class Browser : public WindowListObserver {
|
||||||
// Quit the application immediately without cleanup work.
|
// Quit the application immediately without cleanup work.
|
||||||
void Terminate();
|
void Terminate();
|
||||||
|
|
||||||
|
// Focus the application.
|
||||||
|
void Focus();
|
||||||
|
|
||||||
// Tell the application to open a file.
|
// Tell the application to open a file.
|
||||||
bool OpenFile(const std::string& file_path);
|
bool OpenFile(const std::string& file_path);
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,8 @@ void Browser::Terminate() {
|
||||||
[[AtomApplication sharedApplication] terminate:nil];
|
[[AtomApplication sharedApplication] terminate:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Browser::Focus() {
|
||||||
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue