diff options
authorSamuel Mehrbrodt <>2020-01-29 16:41:02 +0100
committerThorsten Behrens <>2020-02-04 22:17:05 +0100
commita1f07a57e548763c6afd546938caa131a2a22427 (patch)
parentbf0baf83fe1ff3e0b46f18294729ad0dd4598104 (diff)
Place button text in tooltip if it doesn't fit into the button
Seen this happening in custom sidebars (from extensions). When the text is too long for the button, it will get cut off and there is no way to view the button text. Change-Id: I86ce72154e0371bdf24480be41517855dc3ce050 Reviewed-on: Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <> (cherry picked from commit dabb6176407067ef8d46bdde863b087457805c6a) Reviewed-on: Reviewed-by: Adolfo Jayme Barrientos <>
1 files changed, 5 insertions, 0 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 53eaa3ff6b0c..7d235e6bd4c8 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -216,6 +216,11 @@ void Button::ImplDrawAlignedImage(OutputDevice* pDev, Point& rPos,
else if (bDrawText && !bDrawImage && !bHasSymbol)
aOutRect = DrawControlText(*pDev, aOutRect, aText, nTextStyle, nullptr, nullptr);
+ tools::Rectangle textRect = GetTextRect(
+ tools::Rectangle(Point(), Size(0x7fffffff, 0x7fffffff)), aText, nTextStyle);
+ // If the button text doesn't fit into it, put it into a tooltip (might happen in sidebar)
+ if (GetQuickHelpText().isEmpty() && textRect.getWidth() > rSize.getWidth())
+ SetQuickHelpText(aText);
rSize = aOutRect.GetSize();