public void addEditMenuItemsToTreeView(TreeView treeView) { var contextMenu = treeView.add_ContextMenu(); contextMenu.add_MenuItem("delete selected page (you must be an admin)", () => { var pageToDelete = treeView.selected().get_Text(); if (pageToDelete.valid()) { if (WikiApi.deletePage(pageToDelete)) { treeView.remove_Node(treeView.selected()); } } }); /* contextMenu.add_MenuItem("reload all pages", * ()=>{ * treeView.clear(); * treeView.add_Nodes(WikiApi.allPages()); * }); */ var renameMenuItem = contextMenu.add_MenuItem("rename (user will copy, admin will move)"); var renameTextBox = renameMenuItem.add_TextBox("rename"); renameMenuItem.add_MenuItem("rename page with new title (set above)", () => { var currentTitle = treeView.selected().get_Text(); var newTitle = renameTextBox.get_Text(); if (WikiApi.movePage(currentTitle, newTitle)) { treeView.selected().set_Text(newTitle); } //"renaming page '{0}' to '{1}'".info(currentTitle, newTitle); }); treeView.afterSelect <string>( (page) => { renameTextBox.set_Text(page); renameTextBox.width(page.size() * 7); }); }