mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-07 20:38:30 +02:00
Gtk2: delay SetSelLength if it's called from OnChange event of TCustomEdit.
git-svn-id: trunk@36086 -
This commit is contained in:
parent
447f19d6e2
commit
eb25b3d5e7
@ -471,6 +471,7 @@ type
|
|||||||
EventMask: TGdkEventMask;
|
EventMask: TGdkEventMask;
|
||||||
DoubleBuffer: PGdkPixmap;
|
DoubleBuffer: PGdkPixmap;
|
||||||
CursorPos: integer; // needed for delayed SetSelStart
|
CursorPos: integer; // needed for delayed SetSelStart
|
||||||
|
SelLength: integer; // needed for delayed SetSelLength
|
||||||
ControlCursor: HCursor; // current widget cursor
|
ControlCursor: HCursor; // current widget cursor
|
||||||
Flags: TWidgetInfoFlags;
|
Flags: TWidgetInfoFlags;
|
||||||
ChangeLock: Integer; // lock events
|
ChangeLock: Integer; // lock events
|
||||||
|
@ -1182,6 +1182,18 @@ begin
|
|||||||
g_idle_remove_by_data(Data);
|
g_idle_remove_by_data(Data);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function gtk2WSDelayedSetSelLength(Data: Pointer): gboolean; cdecl;
|
||||||
|
var
|
||||||
|
Entry: PGtkEntry;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
Entry := PGtkEntry(PWidgetInfo(Data)^.CoreWidget);
|
||||||
|
gtk_entry_select_region(Entry,
|
||||||
|
PWidgetInfo(Data)^.CursorPos,
|
||||||
|
PWidgetInfo(Data)^.SelLength);
|
||||||
|
g_idle_remove_by_data(Data);
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSCustomEdit.SetCaretPos(const ACustomEdit: TCustomEdit;
|
class procedure TGtk2WSCustomEdit.SetCaretPos(const ACustomEdit: TCustomEdit;
|
||||||
const NewPos: TPoint);
|
const NewPos: TPoint);
|
||||||
var
|
var
|
||||||
@ -1280,14 +1292,25 @@ class procedure TGtk2WSCustomEdit.SetSelLength(
|
|||||||
var
|
var
|
||||||
Entry: PGtkEntry;
|
Entry: PGtkEntry;
|
||||||
SelStart: Integer;
|
SelStart: Integer;
|
||||||
|
WidgetInfo: PWidgetInfo;
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(ACustomEdit, 'SetSelLength') then
|
if not WSCheckHandleAllocated(ACustomEdit, 'SetSelLength') then
|
||||||
Exit;
|
Exit;
|
||||||
Entry := PGtkEntry(ACustomEdit.Handle);
|
Entry := PGtkEntry(ACustomEdit.Handle);
|
||||||
SelStart := GetSelStart(ACustomEdit);
|
SelStart := GetSelStart(ACustomEdit);
|
||||||
gtk_entry_select_region(Entry,
|
|
||||||
SelStart,
|
if LockOnChange(PgtkObject(Entry),0) > 0 then
|
||||||
SelStart + NewLength);
|
begin
|
||||||
|
// delay setting of selection length. issue #20890
|
||||||
|
WidgetInfo := GetWidgetInfo(Entry);
|
||||||
|
if WidgetInfo^.CursorPos = 0 then
|
||||||
|
WidgetInfo^.CursorPos := SelStart;
|
||||||
|
WidgetInfo^.SelLength := SelStart + NewLength;
|
||||||
|
g_idle_add(@gtk2WSDelayedSetSelLength, WidgetInfo);
|
||||||
|
end else
|
||||||
|
gtk_entry_select_region(Entry,
|
||||||
|
SelStart,
|
||||||
|
SelStart + NewLength);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSCustomEdit.SetAlignment(const ACustomEdit: TCustomEdit;
|
class procedure TGtk2WSCustomEdit.SetAlignment(const ACustomEdit: TCustomEdit;
|
||||||
|
Loading…
Reference in New Issue
Block a user