trichview.com Forum Index trichview.com
TRichView support forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[How to] How to switch Insert/Overtype mode

 
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos
View previous topic :: View next topic  
Author Message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6576

PostPosted: Mon Sep 26, 2005 4:53 pm    Post subject: [How to] How to switch Insert/Overtype mode Reply with quote

The overwrite mode is not supported directly, but you can implement it using events.
The code is below.

Code:
var IgnoreNextChar: Boolean = False;

procedure TForm1.RichViewEdit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  IgnoreNextChar := RichViewEdit1.SelectionExists;
end;

procedure TForm1.RichViewEdit1KeyPress(Sender: TObject; var Key: Char);
var rve: TCustomRichViewEdit;
    ItemNo, Offs: Integer;
begin
  if IgnoreNextChar then begin
    IgnoreNextChar := False;
    exit;
  end;
  IgnoreNextChar := False;
  if not ((Key=#9) or (Key>=' ')) then
    exit;
  rve := RichViewEdit1.TopLevelEditor;
  if rve.SelectionExists then
    exit;
  ItemNo := rve.CurItemNo;
  Offs  := rve.OffsetInCurItem;
  if (Offs>=rve.GetOffsAfterItem(ItemNo)) then begin
    if (ItemNo+1<rve.ItemCount) and
       not rve.IsFromNewLine(ItemNo+1) then begin
      inc(ItemNo);
      Offs := rve.GetOffsBeforeItem(ItemNo);
      end
    else
      exit;
  end;
  rve.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs+1);
  rve.Invalidate;
end;
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6576

PostPosted: Thu Jul 19, 2007 7:20 pm    Post subject: Reply with quote

Demo: http://www.trichview.com/support/files/ins.zip

Includes this code + switching modes when user pressed the Insert key.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group