From e599ba0a1d89109a607fe27a514d87c60e26b30f Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 22 Feb 2023 14:19:19 +0000 Subject: [PATCH] spktoolbar: Support accelerator in TSpkPopupMenu items git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8729 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/spktoolbar/SpkGUITools/SpkGUITools.pas | 11 ++++++++--- components/spktoolbar/SpkPopupMenu/spkpopup.pas | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/components/spktoolbar/SpkGUITools/SpkGUITools.pas b/components/spktoolbar/SpkGUITools/SpkGUITools.pas index 8d889a1bd..02f74bb28 100644 --- a/components/spktoolbar/SpkGUITools/SpkGUITools.pas +++ b/components/spktoolbar/SpkGUITools/SpkGUITools.pas @@ -356,7 +356,8 @@ type x, y : integer; const AText : string; TextColor : TColor; - ClipRect : T2DIntRect); overload; + ClipRect : T2DIntRect; + Accel: Boolean = false); overload; class procedure DrawFitWText(ABitmap : TBitmap; x1, x2 : integer; y : integer; @@ -2276,16 +2277,20 @@ begin end; class procedure TGUITools.DrawText(ACanvas: TCanvas; x, y: integer; - const AText: string; TextColor: TColor; ClipRect: T2DIntRect); + const AText: string; TextColor: TColor; ClipRect: T2DIntRect; + Accel: Boolean = false); var WinAPIClipRect: TRect; + ts: TTextStyle; begin WinAPIClipRect := ClipRect.ForWinAPI; with ACanvas do begin Brush.Style := bsClear; Font.Color := TextColor; - TextRect(WinAPIClipRect, x, y, AText); + ts := TextStyle; + ts.ShowPrefix := Accel; + TextRect(WinAPIClipRect, x, y, AText, ts); end; end; diff --git a/components/spktoolbar/SpkPopupMenu/spkpopup.pas b/components/spktoolbar/SpkPopupMenu/spkpopup.pas index b442df3c3..2686251a5 100644 --- a/components/spktoolbar/SpkPopupMenu/spkpopup.pas +++ b/components/spktoolbar/SpkPopupMenu/spkpopup.pas @@ -226,7 +226,7 @@ begin wText := 0; R.Right := ARect.Right - wText; // ClipRect - TGUITools.DrawText(ACanvas, x, y, menuItem.Caption, TextColor, R); + TGUITools.DrawText(ACanvas, x, y, menuItem.Caption, TextColor, R, true); end; end; end;