diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-09-30 16:28:18 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-09-30 16:28:18 +0200 |
commit | 81c34bb5108a8257fd2ccab97611b632d7fa4ffd (patch) | |
tree | b56359c344789d53c4098b016f0325aea979c49d | |
parent | e8820cf9945b9ac0546f8d1cac361336f69c9d27 (diff) | |
download | fpGUI-81c34bb5108a8257fd2ccab97611b632d7fa4ffd.tar.xz |
richview: track cursor position for DocView Notes support
* Now we can click anywhere in the DocView topic to place
our notes.
There are still some minor positioning bugs, but I'll get to that
later.
-rw-r--r-- | docview/components/richtext/RichTextView.pas | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/docview/components/richtext/RichTextView.pas b/docview/components/richtext/RichTextView.pas index f611ab2f..e32c71ee 100644 --- a/docview/components/richtext/RichTextView.pas +++ b/docview/components/richtext/RichTextView.pas @@ -246,8 +246,7 @@ Type PreserveSelection: boolean ); procedure MakeRowVisible( Row: longint ); - procedure MakeRowAndColumnVisible( Row: longint; - Column: longint ); + procedure MakeRowAndColumnVisible(Row: longint; Column: longint); // These two methods set selection start and end, // and redraw the screen, but do not set up cursor. @@ -768,9 +767,23 @@ var Shift: boolean; begin inherited HandleLMouseDown(x, y, shiftstate); + Offset := 0; Position := FindPoint( X, Y, Line, Offset, Link ); FClickedLink := Link; // writeln('Pos=', Ord(Position), ' link=', Link); + + if Position in [tpAboveTextArea, tpBelowTextArea] then + // not on the control (this probably won't happen) + exit; + + // if shift is pressed then keep the same selection start. + Shift := ssShift in ShiftState; + RemoveCursor; + + if not Shift then + ClearSelection; + + SetCursorPosition(Offset, Line, Shift); end; procedure TRichTextView.HandleLMouseUp(x, y: integer; shiftstate: TShiftState); @@ -792,29 +805,25 @@ begin inherited HandleMouseMove(x, y, btnstate, shiftstate); Position := FindPoint(X, Y, Line, Offset, Link); -// if not MouseCapture then // TODO: Introduce a IsMouseCaptured in TfpgWindow + if Link <> FLastLinkOver then begin - if Link <> FLastLinkOver then - begin - if Link <> '' then - begin - if Assigned(FOnOverLink) then - FOnOverLink(Self, Link) - end - else - begin - if Assigned(FOnNotOverLink) then - FOnNotOverLink(Self, FLastLinkOver); - end; - FLastLinkOver := Link; - end; - if Link <> '' then - MouseCursor := mcHand + begin + if Assigned(FOnOverLink) then + FOnOverLink(Self, Link) + end else - MouseCursor := mcDefault; // TODO: later this should be IBeam when RichView supports editing - exit; + begin + if Assigned(FOnNotOverLink) then + FOnNotOverLink(Self, FLastLinkOver); + end; + FLastLinkOver := Link; end; + + if Link <> '' then + MouseCursor := mcHand + else + MouseCursor := mcDefault; // TODO: later this should be IBeam when RichView supports editing end; Destructor TRichTextView.Destroy; @@ -2790,21 +2799,19 @@ begin end; end; -procedure TRichTextView.MakeRowAndColumnVisible( Row: longint; - Column: longint ); +procedure TRichTextView.MakeRowAndColumnVisible(Row: longint; Column: longint); var X: Longint; begin MakeRowVisible( Row ); FLayout.GetXFromOffset( Column, Row, X ); - if X > FXScroll + GetTextAreaWidth then + if X > (FXScroll + GetTextAreaWidth) then // off the right SetHorizontalPosition( X - GetTextAreaWidth + 5 ) else if X < FXScroll then // off to left SetHorizontalPosition( X ); - end; function TRichTextView.LinkFromIndex( const CharIndexToFind: longint): string; |