Skip to content

Commit 8c54a99

Browse files
Update text in shown tooltip
When a tooltip is currently being shown and its text is changed, update the displayed text.
1 parent 60499d9 commit 8c54a99

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

libs/s25main/controls/ctrlBaseTooltip.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@ ctrlBaseTooltip::~ctrlBaseTooltip()
1010
HideTooltip();
1111
}
1212

13+
void ctrlBaseTooltip::SetTooltip(const std::string& tooltip)
14+
{
15+
tooltip_ = tooltip;
16+
if(showing_)
17+
ShowTooltip(tooltip_);
18+
}
19+
1320
void ctrlBaseTooltip::SwapTooltip(ctrlBaseTooltip& other)
1421
{
1522
std::swap(tooltip_, other.tooltip_);
23+
std::swap(showing_, other.showing_);
1624
}
1725

1826
void ctrlBaseTooltip::ShowTooltip() const
@@ -23,9 +31,11 @@ void ctrlBaseTooltip::ShowTooltip() const
2331
void ctrlBaseTooltip::ShowTooltip(const std::string& tooltip) const
2432
{
2533
WINDOWMANAGER.SetToolTip(this, tooltip);
34+
showing_ = true;
2635
}
2736

2837
void ctrlBaseTooltip::HideTooltip() const
2938
{
3039
WINDOWMANAGER.SetToolTip(this, "");
40+
showing_ = false;
3141
}

libs/s25main/controls/ctrlBaseTooltip.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ctrlBaseTooltip
1414
ctrlBaseTooltip(std::string tooltip = "") : tooltip_(std::move(tooltip)) {}
1515
virtual ~ctrlBaseTooltip();
1616

17-
void SetTooltip(const std::string& tooltip) { tooltip_ = tooltip; }
17+
void SetTooltip(const std::string& tooltip);
1818
const std::string& GetTooltip() const { return tooltip_; }
1919
/// Swap the tooltips of those controls
2020
void SwapTooltip(ctrlBaseTooltip& other);
@@ -26,4 +26,5 @@ class ctrlBaseTooltip
2626

2727
protected:
2828
std::string tooltip_;
29+
mutable bool showing_ = false;
2930
};

0 commit comments

Comments
 (0)