summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-10-13 10:00:04 +0200
committerGitHub <noreply@github.com>2020-10-13 10:00:04 +0200
commit1aa8f356e102b525458b627b08257185d7ba5204 (patch)
tree50d258e0ad372ab94447fe07864eacbf27467ab3
parent36e51a8d7e261642958eb18ff1b4ac61673f3b3b (diff)
parent6d510453e5c2ec7cfc411f6883d45e5f217463e5 (diff)
Merge pull request #42489 from auderer/tilemapeditor-refocus
Reset TileMapEditor painting state on application refocus
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp25
-rw-r--r--editor/plugins/tile_map_editor_plugin.h1
2 files changed, 26 insertions, 0 deletions
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 8cd8aaf277..9261113706 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -89,6 +89,25 @@ void TileMapEditor::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
get_tree()->disconnect("node_removed", callable_mp(this, &TileMapEditor::_node_removed));
} break;
+
+ case NOTIFICATION_APPLICATION_FOCUS_OUT: {
+ if (tool == TOOL_PAINTING) {
+ Vector<int> ids = get_selected_tiles();
+
+ if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
+ _set_cell(over_tile, ids, flip_h, flip_v, transpose);
+ _finish_undo();
+
+ paint_undo.clear();
+ }
+
+ tool = TOOL_NONE;
+ _update_button_tool();
+ }
+
+ // set flag to ignore over_tile on refocus
+ refocus_over_tile = true;
+ } break;
}
}
@@ -1299,6 +1318,12 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
CanvasItemEditor::get_singleton()->update_viewport();
}
+ if (refocus_over_tile) {
+ // editor lost focus; forget last tile position
+ old_over_tile = new_over_tile;
+ refocus_over_tile = false;
+ }
+
int tile_under = node->get_cell(over_tile.x, over_tile.y);
String tile_name = "none";
diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h
index 996e904853..f57616db1f 100644
--- a/editor/plugins/tile_map_editor_plugin.h
+++ b/editor/plugins/tile_map_editor_plugin.h
@@ -119,6 +119,7 @@ class TileMapEditor : public VBoxContainer {
Rect2i rectangle;
Point2i over_tile;
+ bool refocus_over_tile = false;
bool *bucket_cache_visited;
Rect2i bucket_cache_rect;