Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can I have right-button click pop-up menu in RichEdit VCL?

972 views
Skip to first unread message

Aku

unread,
Jan 8, 2002, 8:14:25 AM1/8/02
to
Hi friends,

In Memo, when I right-click, there'll appear a pop-up menu, which
include menu items like "Cut","Paste","Copy", etc. But if I use RichEdit,
there's no such pop-up menu.

How can I have this pop-up menu when I right-click in RichEdit?

Thanks a lot!


Mauro Patiño

unread,
Jan 8, 2002, 10:16:10 AM1/8/02
to
Aku wrote:

You'll need to create it from scratch. Assign a popupmenu to your richedit.
Here is some code for the items.

{OnPopup event}
procedure TForm1.PopupMenu1Popup(Sender: TObject);
var
Selected: boolean;
L: integer;
begin
{behave like standard edit menu}
Selected := RichEdit1.SelLength > 0;
mnuCopy.Enabled := Selected;
mnuCut.Enabled := Selected;
mnuDelete.Enabled := Selected;
mnuUndo.Enabled := RichEdit1.Modified;
L := Length(RichEdit1.Text);
mnuSelectAll.Enabled := (L > 0) and (L <> RichEdit1.SelLength-2);
mnuPaste.Enabled := Clipboard.HasFormat(CF_TEXT);
end;

procedure TForm1.mnuCopyClick(Sender: TObject);
begin
RichEdit1.CopyToClipboard;
end;

procedure TForm1.mnuCutClick(Sender: TObject);
begin
RichEdit1.CutToClipboard;
end;

procedure TForm1.mnuPasteClick(Sender: TObject);
begin
RichEdit1.PasteFromClipboard;
end;

procedure TForm1.mnuUndoClick(Sender: TObject);
begin
RichEdit1.Undo;
end;

procedure TForm1.mnuDeleteClick(Sender: TObject);
begin
RichEdit1.ClearSelection;
end;

procedure TForm1.mnuSelectAllClick(Sender: TObject);
begin
RichEdit1.SelectAll;
end;


0 new messages