mirror of
https://github.com/godotengine/godot.git
synced 2025-01-06 17:37:18 +08:00
Reset TileMapEditor painting on application refocus
Treats application unfocus as a mouse release for
TOOL_PAINTING, by finishing the undo state and
resetting the tool. Also sets a flag to prevent extra
lines from being drawn when the application is refocused.
fixes #42398, fixes #24970
(cherry picked from commit 70a4cd1afe
)
This commit is contained in:
parent
b426e58acd
commit
9f4dc87739
@ -93,6 +93,25 @@ void TileMapEditor::_notification(int p_what) {
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
get_tree()->disconnect("node_removed", this, "_node_removed");
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_WM_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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1272,6 +1291,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";
|
||||
|
||||
|
@ -119,6 +119,7 @@ class TileMapEditor : public VBoxContainer {
|
||||
Rect2i rectangle;
|
||||
|
||||
Point2i over_tile;
|
||||
bool refocus_over_tile;
|
||||
|
||||
bool *bucket_cache_visited;
|
||||
Rect2i bucket_cache_rect;
|
||||
|
Loading…
Reference in New Issue
Block a user