- Offizieller Beitrag
To implement ShortCuts You can use the OnKeyDown event.
Code
procedure TForm.WPRichText1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var v: Integer;
begin
if (Key = Integer('B')) and (Shift = [ssctrl]) then
begin WPRichText1.TextCursor.CurrAttribute.ToggleCharstyle(WPSTY_BOLD);
Key := 0;
end
else if (Key = Integer('I')) and (Shift = [ssctrl]) then
begin WPRichText1.TextCursor.CurrAttribute.ToggleCharstyle(WPSTY_ITALIC);
Key := 0;
end
else if (Key = Integer('U')) and (Shift = [ssctrl]) then
begin WPRichText1.TextCursor.CurrAttribute.ToggleCharstyle(WPSTY_UNDERLINE);
Key := 0;
end;
end;
Alles anzeigen
I used to use OnKeyPress for this, but TAB happens to create the same char code as Ctrl+I.