fix: status bar text gets written into the panel right besides the current one, on Linux/macOS

TextRect does not automatically clip on all widgetsets unless you tell it to. On Linux/macOS you must set Canvas.TextStyle so clipping is enabled.
This commit is contained in:
Ansgar Becker
2026-02-25 13:05:35 +01:00
parent 93e1b39f94
commit dfb86d5ae3

View File

@@ -1508,6 +1508,7 @@ var
PanelRect: TRect;
ImageIndex: Integer;
Conn: TDBConnection;
TS: TTextStyle;
begin
// Refresh one status bar panel, probably with icon
ImageIndex := -1;
@@ -1532,6 +1533,11 @@ begin
ImageListMain.DrawForControl(StatusBar.Canvas, PanelRect.Left, PanelRect.Top+2, ImageIndex, ImageListMain.Width, StatusBar);
OffsetRect(PanelRect, Scale96ToForm(ImageListMain.Width)+4, 0);
end;
// Enable clipping, so a longer text does not get written into the panel right besides this one
// If we'd write StatusBar.Canvas.TextStyle.Clipping := True;, we only modify the temporary copy and the change is lost immediately
TS := StatusBar.Canvas.TextStyle; // get record copy
TS.Clipping := True; // modify
StatusBar.Canvas.TextStyle := TS; // write back
StatusBar.Canvas.TextRect(PanelRect, PanelRect.Left, PanelRect.Top+2, Panel.Text);
end;