// Dispatch the help event to the relevant window bool wxContextHelp::DispatchEvent(wxWindow* win, const wxPoint& pt) { wxCHECK_MSG( win, false, wxT("win parameter can't be NULL") ); wxHelpEvent helpEvent(wxEVT_HELP, win->GetId(), pt, wxHelpEvent::Origin_HelpButton); helpEvent.SetEventObject(win); return win->GetEventHandler()->ProcessEvent(helpEvent); }
// Dispatch the help event to the relevant window bool wxContextHelp::DispatchEvent(wxWindow* win, const wxPoint& pt) { wxWindow* subjectOfHelp = win; bool eventProcessed = false; while (subjectOfHelp && !eventProcessed) { wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), pt) ; helpEvent.SetEventObject(subjectOfHelp); eventProcessed = win->GetEventHandler()->ProcessEvent(helpEvent); // Go up the window hierarchy until the event is handled (or not). // I.e. keep submitting ancestor windows until one is recognised // by the app code that processes the ids and displays help. subjectOfHelp = subjectOfHelp->GetParent(); } return eventProcessed; }
LRESULT APIENTRY wxRadioBtnWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { wxRadioBox * const radiobox = wxRadioBox::GetFromRadioButtonHWND(hwnd); wxCHECK_MSG( radiobox, 0, wxT("Should have the associated radio box") ); switch ( message ) { case WM_GETDLGCODE: // we must tell IsDialogMessage()/our kbd processing code that we // want to process arrows ourselves because neither of them is // smart enough to handle arrows properly for us { long lDlgCode = ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, message, wParam, lParam); return lDlgCode | DLGC_WANTARROWS; } case WM_KEYDOWN: { bool processed = true; wxDirection dir; switch ( wParam ) { case VK_UP: dir = wxUP; break; case VK_LEFT: dir = wxLEFT; break; case VK_DOWN: dir = wxDOWN; break; case VK_RIGHT: dir = wxRIGHT; break; default: processed = false; // just to suppress the compiler warning dir = wxALL; } if ( processed ) { int selOld = radiobox->GetSelection(); int selNew = radiobox->GetNextItem ( selOld, dir, radiobox->GetWindowStyle() ); if ( selNew != selOld ) { radiobox->SetSelection(selNew); radiobox->SetFocus(); // emulate the button click radiobox->SendNotificationEvent(); return 0; } } } break; case WM_SETFOCUS: case WM_KILLFOCUS: { // if we don't do this, no focus events are generated for the // radiobox and, besides, we need to notify the parent about // the focus change, otherwise the focus handling logic in // wxControlContainer doesn't work if ( message == WM_SETFOCUS ) radiobox->HandleSetFocus((WXHWND)wParam); else radiobox->HandleKillFocus((WXHWND)wParam); } break; case WM_HELP: { bool processed = false; wxEvtHandler * const handler = radiobox->GetEventHandler(); HELPINFO* info = (HELPINFO*) lParam; if ( info->iContextType == HELPINFO_WINDOW ) { for ( wxWindow* subjectOfHelp = radiobox; subjectOfHelp; subjectOfHelp = subjectOfHelp->GetParent() ) { wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), wxPoint(info->MousePos.x, info->MousePos.y)); helpEvent.SetEventObject(radiobox); if ( handler->ProcessEvent(helpEvent) ) { processed = true; break; } } } else if (info->iContextType == HELPINFO_MENUITEM) { wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId); helpEvent.SetEventObject(radiobox); processed = handler->ProcessEvent(helpEvent); } if ( processed ) return 0; } break; } return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, message, wParam, lParam); }
bool GoForwardActionWidget::event(QEvent *event) { if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick || event->type() == QEvent::Wheel) { QList<GesturesManager::GesturesContext> contexts; contexts << GesturesManager::ToolBarGesturesContext << GesturesManager::GenericGesturesContext; if (GesturesManager::startGesture(this, event, contexts)) { return true; } } if (event->type() == QEvent::ContextMenu) { QContextMenuEvent *contextMenuEvent(static_cast<QContextMenuEvent*>(event)); if (contextMenuEvent) { if (contextMenuEvent->reason() == QContextMenuEvent::Mouse) { contextMenuEvent->accept(); return true; } event->accept(); Window *window(getWindow()); QMenu menu(this); menu.addAction(window ? window->getContentsWidget()->getAction(ActionsManager::ClearTabHistoryAction) : ActionsManager::getAction(ActionsManager::ClearTabHistoryAction, this)); menu.addAction(window ? window->getContentsWidget()->getAction(ActionsManager::PurgeTabHistoryAction) : ActionsManager::getAction(ActionsManager::PurgeTabHistoryAction, this)); ToolBarWidget *toolBar = qobject_cast<ToolBarWidget*>(parentWidget()); if (toolBar) { menu.addSeparator(); menu.addActions(ToolBarWidget::createCustomizationMenu(toolBar->getIdentifier(), QList<QAction*>(), &menu)->actions()); } menu.exec(contextMenuEvent->globalPos()); return true; } return false; } if (event->type() == QEvent::ToolTip) { QHelpEvent *helpEvent(dynamic_cast<QHelpEvent*>(event)); if (helpEvent) { const QVector<QKeySequence> shortcuts(ActionsManager::getActionDefinition(ActionsManager::GoForwardAction).shortcuts); QString toolTip(text() + (shortcuts.isEmpty() ? QString() : QLatin1String(" (") + shortcuts.at(0).toString(QKeySequence::NativeText) + QLatin1Char(')'))); if (getWindow()) { const WindowHistoryInformation history(getWindow()->getContentsWidget()->getHistory()); if (!history.entries.isEmpty() && history.index < (history.entries.count() - 1)) { QString title(history.entries.at(history.index + 1).title); title = (title.isEmpty() ? tr("(Untitled)") : title.replace(QLatin1Char('&'), QLatin1String("&&"))); toolTip = title + QLatin1String(" (") + text() + (shortcuts.isEmpty() ? QString() : QLatin1String(" - ") + shortcuts.at(0).toString(QKeySequence::NativeText)) + QLatin1Char(')'); } } QToolTip::showText(helpEvent->globalPos(), toolTip); } return true; } return ActionWidget::event(event); }
void DhQGraphicsScene::DvhhelpEvent(QGraphicsSceneHelpEvent* x1) { return helpEvent(x1); }