diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index f1e78b9b59..ce5e3512f9 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -842,6 +842,12 @@ struct TooltipsWindow : public Window this->delete_next_mouse_loop = true; } break; + + case TCC_EXIT_VIEWPORT: { + Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y); + if (w == nullptr || IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y) == nullptr) this->delete_next_mouse_loop = true; + break; + } } } }; diff --git a/src/viewport.cpp b/src/viewport.cpp index d5abae13c3..d30f581a95 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -4869,7 +4869,7 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t return (int)(h1 - h0) * TILE_HEIGHT_STEP; } -static void ShowLengthMeasurement(HighLightStyle style, TileIndex start_tile, TileIndex end_tile, TooltipCloseCondition close_cond = TCC_NONE, bool show_single_tile_length = false) +static void ShowLengthMeasurement(HighLightStyle style, TileIndex start_tile, TileIndex end_tile, TooltipCloseCondition close_cond = TCC_EXIT_VIEWPORT, bool show_single_tile_length = false) { static const StringID measure_strings_length[] = {STR_NULL, STR_MEASURE_LENGTH, STR_MEASURE_LENGTH_HEIGHTDIFF}; @@ -5353,7 +5353,7 @@ static HighLightStyle CalcPolyrailDrawstyle(Point pt, bool dragging) } HighLightStyle ret = HT_LINE | (HighLightStyle)TrackdirToTrack(seldir); - ShowLengthMeasurement(ret, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), TCC_NONE, true); + ShowLengthMeasurement(ret, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), TCC_EXIT_VIEWPORT, true); return ret; } @@ -5475,7 +5475,7 @@ calc_heightdiff_single_direction:; params[index++] = GetTileMaxZ(t1) * TILE_HEIGHT_STEP; params[index++] = heightdiff; //Show always the measurement tooltip - GuiShowTooltips(_thd.GetCallbackWnd(),STR_MEASURE_DIST_HEIGHTDIFF, index, params, TCC_NONE); + GuiShowTooltips(_thd.GetCallbackWnd(),STR_MEASURE_DIST_HEIGHTDIFF, index, params, TCC_EXIT_VIEWPORT); break; } diff --git a/src/window_gui.h b/src/window_gui.h index 3244cac2b3..bcdd9221bb 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -285,6 +285,7 @@ enum TooltipCloseCondition { TCC_NONE, TCC_HOVER_VIEWPORT, TCC_NEXT_LOOP, + TCC_EXIT_VIEWPORT, }; struct WindowBase {