void WsMenu::onMouseWentOver(WPushButton* pButton) { if ( !pButton ) return; if ( !pButton->menu() ) return; WPopupMenu* pPopup = dynamic_cast<WPopupMenu*>(pButton->menu()); if ( asString(option("align")) == "right" ) pPopup->popup(pButton, Wt::Horizontal); else pPopup->popup(pButton, Wt::Vertical); }
/*! \brief Show a popup for a folder item. */ void showPopup(const WModelIndex& item, const WMouseEvent& event) { if (event.button() == WMouseEvent::RightButton) { // Select the item, it was not yet selected. if (!folderView_->isSelected(item)) folderView_->select(item); if (!popup_) { popup_ = new WPopupMenu(); popup_->addItem("icons/folder_new.gif", "Create a New Folder"); popup_->addItem("Rename this Folder")->setCheckable(true); popup_->addItem("Delete this Folder"); popup_->addSeparator(); popup_->addItem("Folder Details"); popup_->addSeparator(); popup_->addItem("Application Inventory"); popup_->addItem("Hardware Inventory"); popup_->addSeparator(); WPopupMenu *subMenu = new WPopupMenu(); subMenu->addItem("Sub Item 1"); subMenu->addItem("Sub Item 2"); popup_->addMenu("File Deployments", subMenu); /* * This is one method of executing a popup, which does not block a * thread for a reentrant event loop, and thus scales. * * Alternatively you could call WPopupMenu::exec(), which returns * the result, but while waiting for it, blocks the thread. */ popup_->aboutToHide().connect(this, &TreeViewDragDrop::popupAction); } if (popup_->isHidden()) popup_->popup(event); else popup_->hide(); } }