At the moment I have the following hack:
procedure TForm1.HTMLViewer1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = Word('C')) and (Shift = [ssCtrl]) then
HTMLViewer1.CopyToClipboard;
end;
Is there a more sensible/maintainable way of enabling copying from an htmlviewer? I am hoping that there is a property that I can set, or something, because having to do the above seems stupid. Descendants of TCustomEdit have copying, pasting and select-all-ing by default, but htmlviewer for some reason doesnt seem to be implemented this way.
Another problem is that the above method also doesnt account for right-clicking and selecting "copy"
EDIT: In the end I chose to replace the above code with a proper context menu, as per this tutorial: http://delphi.about.com/od/tmemotrichedit/a/richedit-popup.htm
You could do something when the user presses Ctrl-C (ie. use your own solution #1)
procedure TForm1.HTMLViewer1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key = Word('C')) and (Shift = [ssCtrl]) then
HTMLViewer1.CopyToClipboard;
end;
or you could implement a popup menu as described here (ie. your own solution #2)