mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 01:39:25 +02:00
GTK3: Enable showing hot key in page control widgets caption.
We store the raw caption in the `Text` field and convert ampersands (`&`) to underscores (`_`) before using `set_markup_with_mnemonic` to update the label text while honoring the hot key definition. NB: The underscore will be drawn only if user hits `alt` key which is a Gnome/Gtk3 feature. This fix is related to #40713.
This commit is contained in:
parent
e45713b7f8
commit
93f05421b2
@ -373,7 +373,6 @@ type
|
|||||||
FPageLabel: PGtkLabel;
|
FPageLabel: PGtkLabel;
|
||||||
protected
|
protected
|
||||||
procedure setText(const AValue: String); override;
|
procedure setText(const AValue: String); override;
|
||||||
function getText: String; override;
|
|
||||||
function CreateWidget(const Params: TCreateParams):PGtkWidget; override;
|
function CreateWidget(const Params: TCreateParams):PGtkWidget; override;
|
||||||
procedure DestroyWidget; override;
|
procedure DestroyWidget; override;
|
||||||
public
|
public
|
||||||
@ -4501,21 +4500,14 @@ procedure TGtk3Page.setText(const AValue: String);
|
|||||||
var
|
var
|
||||||
bs:string;
|
bs:string;
|
||||||
begin
|
begin
|
||||||
|
inherited;
|
||||||
if Assigned(FPageLabel) then
|
if Assigned(FPageLabel) then
|
||||||
begin
|
begin
|
||||||
bs:=ReplaceAmpersandsWithUnderscores(Avalue);
|
bs:=ReplaceAmpersandsWithUnderscores(Avalue);
|
||||||
FPageLabel^.set_text(PChar(bs));
|
FPageLabel^.set_markup_with_mnemonic(PChar(bs));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtk3Page.getText: String;
|
|
||||||
begin
|
|
||||||
if Assigned(FPageLabel) then
|
|
||||||
Result := FPageLabel^.get_text
|
|
||||||
else
|
|
||||||
Result := '';
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TGtk3Page.CreateWidget(const Params: TCreateParams): PGtkWidget;
|
function TGtk3Page.CreateWidget(const Params: TCreateParams): PGtkWidget;
|
||||||
begin
|
begin
|
||||||
FWidgetType := FWidgetType + [wtContainer];
|
FWidgetType := FWidgetType + [wtContainer];
|
||||||
@ -7588,6 +7580,7 @@ begin
|
|||||||
FWidgetType := [wtWidget, wtLayout, wtScrollingWin, wtCustomControl]
|
FWidgetType := [wtWidget, wtLayout, wtScrollingWin, wtCustomControl]
|
||||||
end;
|
end;
|
||||||
Result^.set_size_request(Params.Width, Params.Height);
|
Result^.set_size_request(Params.Width, Params.Height);
|
||||||
|
Text := Params.Caption;
|
||||||
|
|
||||||
FBox := TGtkVBox.new(GTK_ORIENTATION_VERTICAL, 0);
|
FBox := TGtkVBox.new(GTK_ORIENTATION_VERTICAL, 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user