Merge pull request #47744 from KoBeWi/press_F_to_play_exit
This commit is contained in:
commit
6e6287f748
3 changed files with 34 additions and 2 deletions
|
@ -258,6 +258,11 @@ Error EditorRun::run(const String &p_scene, const String &p_write_movie) {
|
|||
}
|
||||
}
|
||||
|
||||
// Pass the debugger stop shortcut to the running instance(s).
|
||||
String shortcut;
|
||||
VariantWriter::write_to_string(ED_GET_SHORTCUT("editor/stop"), shortcut);
|
||||
OS::get_singleton()->set_environment("__GODOT_EDITOR_STOP_SHORTCUT__", shortcut);
|
||||
|
||||
printf("Running: %s", exec.utf8().get_data());
|
||||
for (const String &E : args) {
|
||||
printf(" %s", E.utf8().get_data());
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/debugger/engine_debugger.h"
|
||||
#include "core/input/shortcut.h"
|
||||
#include "core/string/translation.h"
|
||||
#include "core/variant/variant_parser.h"
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
#include "scene/theme/theme_db.h"
|
||||
|
@ -1034,9 +1036,31 @@ bool Window::_can_consume_input_events() const {
|
|||
|
||||
void Window::_window_input(const Ref<InputEvent> &p_ev) {
|
||||
if (EngineDebugger::is_active()) {
|
||||
// Quit from game window using F8.
|
||||
// Quit from game window using the stop shortcut (F8 by default).
|
||||
// The custom shortcut is provided via environment variable when running from the editor.
|
||||
if (debugger_stop_shortcut.is_null()) {
|
||||
String shortcut_str = OS::get_singleton()->get_environment("__GODOT_EDITOR_STOP_SHORTCUT__");
|
||||
if (!shortcut_str.is_empty()) {
|
||||
Variant shortcut_var;
|
||||
|
||||
VariantParser::StreamString ss;
|
||||
ss.s = shortcut_str;
|
||||
|
||||
String errs;
|
||||
int line;
|
||||
VariantParser::parse(&ss, shortcut_var, errs, line);
|
||||
debugger_stop_shortcut = shortcut_var;
|
||||
}
|
||||
|
||||
if (debugger_stop_shortcut.is_null()) {
|
||||
// Define a default shortcut if it wasn't provided or is invalid.
|
||||
debugger_stop_shortcut.instantiate();
|
||||
debugger_stop_shortcut->set_events({ (Variant)InputEventKey::create_reference(Key::F8) });
|
||||
}
|
||||
}
|
||||
|
||||
Ref<InputEventKey> k = p_ev;
|
||||
if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == Key::F8) {
|
||||
if (k.is_valid() && k->is_pressed() && !k->is_echo() && debugger_stop_shortcut->matches_event(k)) {
|
||||
EngineDebugger::get_singleton()->send_message("request_quit", Array());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
class Control;
|
||||
class Font;
|
||||
class Shortcut;
|
||||
class StyleBox;
|
||||
class Theme;
|
||||
|
||||
|
@ -151,6 +152,8 @@ private:
|
|||
void _event_callback(DisplayServer::WindowEvent p_event);
|
||||
virtual bool _can_consume_input_events() const override;
|
||||
|
||||
Ref<Shortcut> debugger_stop_shortcut;
|
||||
|
||||
protected:
|
||||
Viewport *_get_embedder() const;
|
||||
virtual Rect2i _popup_adjust_rect() const { return Rect2i(); }
|
||||
|
|
Loading…
Reference in a new issue