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
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
You may try the following:
if (WPEditor->TextCursor()->Inserting)
{
// insert mode
}
else
{
// overwrite mode
}
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;
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;