문제

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)

Add a Standard Context (popup) Menu to Delphi's TRichEdit

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top