WPCubed Product Support

Insert/overwrite mode

Hi

How do I know if Caret is in Insert/Overwrite-Mode? Which event
i have to use (to update Statusbar, if it changes) ?

Thanks

#1 ♥ 0
5.2k Views 4 users read 1 min

You may try the following:

if (WPEditor->TextCursor()->Inserting)
 {
 // insert mode
 }
else
 {
 // overwrite mode
 }
#2 ♥ 0

In any program you may use the GetKeyState API function:

if HiWord(GetKeyState(vk_Insert)) <> 0 then
ShowMessage('Insert')
else
ShowMessage('Overwrite') ;

The pressing of the Ins key can be caught when the program is idle:

private
procedure CheckKey(Sender: TObject; var Done: Boolean);

procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnIdle := CheckKey;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
Application.OnIdle := nil
end;

procedure TForm1.CheckKey(Sender: TObject; var Done: Boolean);
begin
if HiWord(GetKeyState(vk_Insert)) <> 0 then
//whatever
end;

#3 ♥ 0
support

In any program you may use the GetKeyState API function:

Thank You. This is interesting.

WPTools does it differently. It toggles the Inserting mode (property = same name) when VK_INSERT is pressed.

procedure TWPCustomRtfEdit.KeyDown(var Key: Word; Shift: TShiftState);
...

if not TextCursor.Inserting or not
              (wpAlwaysInsert in EditOptions) then
            begin
              TextCursor.Inserting := not TextCursor.Inserting;
              DoUpdateEditState;
            end;
#4 ♥ 0
This category is archived. No new posts are possible.