mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-07 17:37:39 +01:00
Gtk3: implemented SetSelText for GtkEntry.
This commit is contained in:
parent
56bec1de09
commit
53561a732a
@ -270,6 +270,7 @@ type
|
||||
procedure SetNumbersOnly(ANumbersOnly:boolean);
|
||||
procedure SetTextHint(const AHint:string);
|
||||
procedure SetFrame(const aborder:boolean);
|
||||
procedure SetSelText(const ASelText: string);
|
||||
function GetTextHint:string;
|
||||
function IsWidgetOk: Boolean; override;
|
||||
property Alignment: TAlignment read GetAlignment write SetAlignment;
|
||||
@ -4229,6 +4230,23 @@ begin
|
||||
PGtkEntry(Widget)^.set_has_frame(aborder);
|
||||
end;
|
||||
|
||||
procedure TGtk3Entry.SetSelText(const ASelText: string);
|
||||
var
|
||||
AEntry: PGtkEntry;
|
||||
AText: Pgchar;
|
||||
APos: SizeInt;
|
||||
begin
|
||||
if not IsWidgetOK then
|
||||
exit;
|
||||
AEntry := PGtkEntry(Widget);
|
||||
AText := AEntry^.get_text;
|
||||
if AText = nil then
|
||||
exit;
|
||||
APos := Pos(aSelText, StrPas(AText));
|
||||
if APos > 0 then
|
||||
PGtkEditable(AEntry)^.select_region(APos - 1, APos - 1 + length(ASelText));
|
||||
end;
|
||||
|
||||
function TGtk3Entry.GetTextHint:string;
|
||||
|
||||
begin
|
||||
|
||||
@ -169,6 +169,7 @@ type
|
||||
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
|
||||
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
||||
class procedure SetSelText(const ACustomEdit: TCustomEdit; const NewSelText: string); override;
|
||||
class procedure SetTextHint(const ACustomEdit: TCustomEdit; const ATextHint: string); override;
|
||||
|
||||
class procedure Cut(const ACustomEdit: TCustomEdit); override;
|
||||
@ -830,6 +831,16 @@ begin
|
||||
TGtk3Editable(ACustomEdit.Handle).EndUpdate;
|
||||
end;
|
||||
|
||||
class procedure TGtk3WSCustomEdit.SetSelText(const ACustomEdit: TCustomEdit;
|
||||
const NewSelText: string);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ACustomEdit, 'SetSelText') then
|
||||
Exit;
|
||||
TGtk3Entry(ACustomEdit.Handle).BeginUpdate;
|
||||
TGtk3Entry(ACustomEdit.Handle).SetSelText(NewSelText);
|
||||
TGtk3Entry(ACustomEdit.Handle).EndUpdate;
|
||||
end;
|
||||
|
||||
class procedure TGtk3WSCustomEdit.SetTextHint(const ACustomEdit: TCustomEdit;
|
||||
const ATextHint: string);
|
||||
begin
|
||||
|
||||
Loading…
Reference in New Issue
Block a user