From a7d192079f7dc776f5bab268f2ef073aa5aa6ba1 Mon Sep 17 00:00:00 2001 From: skalogryz Date: Thu, 6 Jul 2017 20:49:49 +0000 Subject: [PATCH] richmemo: temporary workaround to prevent scrolling on style change git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5970 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/richmemo/richmemo.pas | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/richmemo/richmemo.pas b/components/richmemo/richmemo.pas index b37802aa4..f81097007 100644 --- a/components/richmemo/richmemo.pas +++ b/components/richmemo/richmemo.pas @@ -864,6 +864,7 @@ var p : TFontParams; allowInternalChange: Boolean; fp : TFontParams; + h,v : integer; const AllFontStyles : TFontStyles = [fsBold, fsItalic, fsUnderline, fsStrikeOut]; begin @@ -871,6 +872,8 @@ begin if (ModifyMask = []) or (TextLength = 0) then Exit; + h:=Self.HorzScrollBar.Position; + v:=Self.VertScrollBar.Position; allowInternalChange:=(not (tmm_Styles in ModifyMask)) or (AddFontStyle+RemoveFontStyle=AllFontStyles); if allowInternalChange and (TWSCustomRichMemoClass(WidgetSetClass).isInternalChange(Self, ModifyMask)) then @@ -883,6 +886,8 @@ begin Exit; end; + //todo: this is temporary workaround + // the style changing should not be adjusting the scroll Lines.BeginUpdate; try // manually looping from text ranges and re-applying @@ -907,7 +912,11 @@ begin inc(i, l); end; finally - Lines.EndUpdate + // todo: this is a workaround. + // getting position is necessary, so the cached values are refershed + if Self.HorzScrollBar.Position<>h then Self.HorzScrollBar.Position:=h; + if Self.VertScrollBar.Position<>v then Self.VertScrollBar.Position:=v; + Lines.EndUpdate; end; end;