[wxWidgets]_[初级]_[Mac OS X下添加输入框的右键菜单]


场景:

1.在Mac OS X 下,输入文本框wxTextCtrl默认是没有默认右键菜单的,这样对使用鼠标惯的用户来说是不清楚还能按Command+V的,还有粘帖,复制等操作.


可通过以下操作添加右键菜单:

text_->Connect(wxEVT_CONTEXT_MENU,wxContextMenuEventHandler(RegisterDialog::OnContextMenu),NULL,this);

void RegisterDialog::OnContextMenu(wxContextMenuEvent& event)
{
	wxMenu* menu = new wxMenu();
	// Some standard items
	menu->Append(wxID_UNDO, _("&Undo"));
	menu->Append(wxID_REDO, _("&Redo"));
	menu->AppendSeparator();
	menu->Append(wxID_CUT, _("Cu&t"));
	menu->Append(wxID_COPY, _("&Copy"));
	menu->Append(wxID_PASTE, _("&Paste"));
	menu->Append(wxID_CLEAR, _("&Delete"));
	menu->AppendSeparator();
	menu->Append(wxID_SELECTALL, _("Select &All"));

	// Add any custom items here

	PopupMenu(menu);
}


你可能感兴趣的:(文本框,右键菜单,wxwidgets,macosx,wxTextCtrl)