bool Widget::TriggerKeyDown(const KeyboardEvent &event, bool handled) { HandleKeyDown(event); if (!handled) handled = onKeyDown.emit(event); if (GetContainer()) handled = GetContainer()->TriggerKeyDown(event, handled); return handled; }
bool Widget::TriggerKeyDown(const KeyboardEvent &event, bool emit) { HandleKeyDown(event); if (emit) emit = !onKeyDown.emit(event); if (GetContainer()) GetContainer()->TriggerKeyDown(event, emit); return !emit; }
void HandleEvents() { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_QUIT: g_quit = true; break; case SDL_KEYDOWN: HandleKeyDown(event.key.keysym.sym); break; case SDL_MOUSEMOTION: g_mouseX = event.button.x; g_mouseY = event.button.y; break; case SDL_MOUSEBUTTONDOWN: g_clickX = event.button.x; g_clickY = event.button.y; HandleClick( g_clickX, g_clickY ); break; default: break; } } }
bool wxComboBox::MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam) { switch ( msg ) { case WM_CHAR: // for compatibility with wxTextCtrl, generate a special message // when Enter is pressed if ( wParam == VK_RETURN ) { if (SendMessage(GetHwnd(), CB_GETDROPPEDSTATE, 0, 0)) return false; wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); const int sel = GetSelection(); event.SetInt(sel); event.SetString(GetValue()); InitCommandEventWithItems(event, sel); if ( ProcessCommand(event) ) { // don't let the event through to the native control // because it doesn't need it and may generate an annoying // beep if it gets it return true; } } // fall through case WM_SYSCHAR: return HandleChar(wParam, lParam); case WM_SYSKEYDOWN: case WM_KEYDOWN: return HandleKeyDown(wParam, lParam); case WM_SYSKEYUP: case WM_KEYUP: return HandleKeyUp(wParam, lParam); case WM_SETFOCUS: return HandleSetFocus((WXHWND)wParam); case WM_KILLFOCUS: return HandleKillFocus((WXHWND)wParam); case WM_CUT: case WM_COPY: case WM_PASTE: return HandleClipboardEvent(msg); } return false; }
BOOL CEditTreeCtrl::PreTranslateMessage(MSG* pMsg) { switch(pMsg->message) { case WM_KEYDOWN: if(HandleKeyDown(pMsg->wParam, pMsg->lParam)) return true; break; default: break; } return CTreeCtrl::PreTranslateMessage(pMsg); }
BOOL CQListCtrl::PreTranslateMessage(MSG* pMsg) { CAccel a; if(m_Accels.OnMsg(pMsg, a)) { switch(a.Cmd) { case COPY_BUFFER_HOT_KEY_1_ID: PutSelectedItemOnDittoCopyBuffer(0); break; case COPY_BUFFER_HOT_KEY_2_ID: PutSelectedItemOnDittoCopyBuffer(1); break; case COPY_BUFFER_HOT_KEY_3_ID: PutSelectedItemOnDittoCopyBuffer(2); break; default: if(a.RefId == CHotKey::PASTE_OPEN_CLIP) { GetParent()->SendMessage(NM_SELECT_DB_ID, a.Cmd, 0); } else if(a.RefId == CHotKey::MOVE_TO_GROUP) { GetParent()->SendMessage(NM_MOVE_TO_GROUP, a.Cmd, 0); } } return TRUE; } if(VALID_TOOLTIP) { if(m_pToolTip->OnMsg(pMsg)) return TRUE; } switch(pMsg->message) { case WM_KEYDOWN: if(HandleKeyDown(pMsg->wParam, pMsg->lParam)) return TRUE; break; // end case WM_KEYDOWN case WM_VSCROLL: ASSERT(FALSE); break; } // end switch(pMsg->message) return CListCtrl::PreTranslateMessage(pMsg); }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_KEYDOWN: HandleKeyDown(wParam); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; }
bool PawsManager::HandleEvent( iEvent &event ) { if (event.Name == MouseMove) return HandleMouseMove (event); if (event.Name == MouseDown) return HandleMouseDown (event); if (event.Name == MouseDoubleClick) return HandleDoubleClick (event); if (event.Name == MouseUp) return HandleMouseUp (event); if (event.Name == KeyboardDown || event.Name == KeyboardUp) return HandleKeyDown( event ); return false; }
void InputHandler::handleEvent(Event *e) { /* make sure we are getting events from the correct place */ if (e->getDispatcher() == coreInput) { InputEvent *ie = (InputEvent*) e; switch (ie->getEventCode()) { case InputEvent::EVENT_KEYDOWN: HandleKeyDown(ie->getKey()); break; case InputEvent::EVENT_KEYUP: HandleKeyUp(ie->getKey()); break; } } }
BOOL CQListCtrl::PreTranslateMessage(MSG* pMsg) { DWORD dID; if(m_Accels.OnMsg(pMsg, dID)) { switch(dID) { case COPY_BUFFER_HOT_KEY_1_ID: PutSelectedItemOnDittoCopyBuffer(0); break; case COPY_BUFFER_HOT_KEY_2_ID: PutSelectedItemOnDittoCopyBuffer(1); break; case COPY_BUFFER_HOT_KEY_3_ID: PutSelectedItemOnDittoCopyBuffer(2); break; default: GetParent()->SendMessage(NM_SELECT_DB_ID, dID, 0); } return TRUE; } if(m_pToolTip) { if(m_pToolTip->OnMsg(pMsg)) return TRUE; } switch(pMsg->message) { case WM_KEYDOWN: if(HandleKeyDown(pMsg->wParam, pMsg->lParam)) return TRUE; break; // end case WM_KEYDOWN case WM_VSCROLL: ASSERT(FALSE); break; } // end switch(pMsg->message) return CListCtrl::PreTranslateMessage(pMsg); }
void CPlayerController::HandleEvent(const ALLEGRO_EVENT& ev) { if (!m_player) return; if (ev.type == ALLEGRO_EVENT_MOUSE_AXES) { HandleMouseMove(ev); } else if (ev.type == ALLEGRO_EVENT_KEY_DOWN || ev.type == ALLEGRO_EVENT_KEY_CHAR) { m_keys[ev.keyboard.keycode] = true; HandleKeyDown(ev); } else if(ev.type == ALLEGRO_EVENT_KEY_UP) { m_keys[ev.keyboard.keycode] = false; HandleKeyUp(ev); } }
bool wxComboBox::ProcessEditMsg( WXUINT uMsg , WXWPARAM wParam , WXLPARAM lParam) { SHORT vFlag; switch (uMsg) { case WM_CHAR: vFlag = SHORT1FROMMP(wParam); switch(vFlag) { case KC_CHAR: return (HandleChar( wParam ,lParam ,true /* isASCII */ )); case KC_PREVDOWN: return (HandleKeyDown( wParam ,lParam )); case KC_KEYUP: return (HandleKeyUp( wParam ,lParam )); } break; case WM_SETFOCUS: if (SHORT1FROMMP((MPARAM)lParam) == TRUE) return(HandleSetFocus((WXHWND)(HWND)wParam)); else return(HandleKillFocus((WXHWND)(HWND)wParam)); break; } return false; } // end of WinGuiBase_CComboBox::ProcessEditMsg
// -------------------------------------------------------------------------------------- static void handleEvents(EventRecord *event) { WindowRef window; Boolean activate; WindowPartCode partCode; OSErr error; Rect tempRect, newSize; long menuChoice; MenuCommand commandID; RgnHandle grayRegion; switch (event->what) // handle events according to the priority { // determined by the system case activateEvt: window = (WindowRef)event->message; activate = (event->modifiers & activeFlag) != 0; HandleActivate(window, activate); break; case mouseDown: partCode = FindWindow(event->where, &window); switch(partCode) { case inMenuBar: menuChoice = MenuSelect(event->where); error = GetMenuItemCommandID(GetMenuRef(HiWord(menuChoice)), LoWord(menuChoice), &commandID); if (error == noErr) { if (commandID == 0) // if the menu item clicked on does not have commandID = (MenuCommand)menuChoice; // a command ID HandleMenuChoice(commandID); } break; case inSysWindow: if (window != NULL) SystemClick(event, window); break; case inContent: // the following window part codes will only be returned if (window != FrontWindow()) // for the preferences window SelectWindow(window); else HandleContentClick(window, event->where, event->modifiers); break; case inDrag: grayRegion = GetGrayRgn(); DragWindow(window, event->where, &((*grayRegion)->rgnBBox)); break; case inGrow: SetRect(&tempRect, kPrefsWindowPlatinumWidth, kPrefsWindowPlatinumHeight, SHRT_MAX, SHRT_MAX); ResizeWindow(window, event->where, &tempRect, &newSize); AdjustControls(window); break; case inGoAway: ClosePrefsWindow(window); break; } break; case keyDown: case autoKey: // a separate auto key handler would go after disk events if ((event->modifiers & cmdKey) != 0) { UInt32 keyMenuChoice; keyMenuChoice = MenuEvent(event); error = GetMenuItemCommandID(GetMenuRef(HiWord(keyMenuChoice)), LoWord(keyMenuChoice), &commandID); if (error == noErr) { if (commandID == 0) // if the menu item chosen does not have a commandID = (MenuCommand)keyMenuChoice; // command ID HandleMenuChoice(commandID); // (but they all should) } } else { window = FrontNonFloatingWindow(); if (window != NULL) { char keyCode = (event->message & keyCodeMask) >> 8; HandleKeyDown(keyCode, window); } } break; case diskEvt: if (HiWord(event->message) != noErr) { Point where; SetPt(&where, 70, 50); ShowCursor(); DIBadMount(where, event->message); } break; case updateEvt: window = (WindowRef)event->message; SetPortWindowPort(window); BeginUpdate(window); HandleDrawContent(window); EndUpdate(window); break; case kHighLevelEvent: // an OS Event handler would go before high level events AEProcessAppleEvent(event); break; }
/** ** Handle keyboard! */ local void X11HandleKey(KeySym code) { int icode; /* ** Convert X11 keycodes into internal keycodes. */ switch( (icode=code) ) { case XK_Escape: icode='\e'; break; case XK_Return: icode='\r'; break; case XK_BackSpace: icode='\b'; break; case XK_Tab: icode='\t'; break; case XK_Up: icode=KeyCodeUp; break; case XK_Down: icode=KeyCodeDown; break; case XK_Left: icode=KeyCodeLeft; break; case XK_Right: icode=KeyCodeRight; break; case XK_Pause: icode=KeyCodePause; break; // We need these because if you only hit a modifier key, // X doesn't set its state (modifiers) field in the keyevent. case XK_Shift_L: case XK_Shift_R: KeyModifiers|=ModifierShift; break; case XK_Control_L: case XK_Control_R: KeyModifiers|=ModifierControl; break; case XK_Alt_L: case XK_Alt_R: case XK_Meta_L: case XK_Meta_R: KeyModifiers|=ModifierAlt; break; case XK_Super_L: case XK_Super_R: KeyModifiers|=ModifierSuper; break; case XK_Hyper_L: case XK_Hyper_R: KeyModifiers|=ModifierHyper; break; default: break; } if( HandleKeyDown(icode) ) { return; } DoBottomPanelKey(icode); }
/* ================ rvGEWorkspace::HandleMessage Handles window messages to the workspace ================ */ void rvGEWorkspace::HandleMessage ( UINT msg, WPARAM wParam, LPARAM lParam ) { switch ( msg ) { case WM_CLOSE: { if ( IsModified ( ) ) { if ( IDYES == gApp.MessageBox ( va("Save changes to the document \"%s\" before closing?", GetFilename() ), MB_YESNO|MB_ICONQUESTION ) ) { SendMessage ( mApplication->GetMDIFrame(), WM_COMMAND, MAKELONG(ID_GUIED_FILE_SAVE,0), 0 ); } } GetApplication ( )->GetNavigator().SetWorkspace(NULL); GetApplication ( )->GetTransformer().SetWorkspace(NULL); GetApplication ( )->GetProperties().SetWorkspace(NULL); break; } case WM_CAPTURECHANGED: if ( (HWND)lParam != mWnd ) { mDragScroll = false; mDragType = rvGESelectionMgr::HT_NONE; } break; case WM_SETCURSOR: { POINT point; idVec2 cursor; GetCursorPos ( &point ); cursor.Set ( point.x, point.y ); WindowToWorkspace ( cursor ); if ( mDragType == rvGESelectionMgr::HT_NONE ) { UpdateCursor ( cursor.x, cursor.y ); } else { UpdateCursor ( mDragType ); } break; } case WM_MOUSEWHEEL: if ( (short)HIWORD(wParam) > 0 ) { ZoomIn ( ); } else if ( (short)HIWORD(wParam) < 0 ) { ZoomOut ( ); } break; case WM_MOUSEMOVE: HandleMouseMove ( wParam, lParam ); break; case WM_MBUTTONDOWN: HandleMButtonDown ( wParam, lParam ); break; case WM_MBUTTONUP: HandleMButtonUp ( wParam, lParam ); break; case WM_LBUTTONDOWN: HandleLButtonDown ( wParam, lParam ); break; case WM_LBUTTONUP: HandleLButtonUp ( wParam, lParam ); break; case WM_LBUTTONDBLCLK: HandleLButtonDblClk ( wParam, lParam ); break; case WM_INITMENUPOPUP: SendMessage ( mApplication->GetMDIFrame(), msg, wParam, lParam ); break; case WM_COMMAND: HandleCommand ( wParam, lParam ); break; case WM_RBUTTONDOWN: HandleRButtonDown ( wParam, lParam ); break; case WM_SIZE: UpdateScrollbars(); break; case WM_VSCROLL: HandleScroll ( SB_VERT, wParam, lParam ); break; case WM_HSCROLL: HandleScroll ( SB_HORZ, wParam, lParam ); break; case WM_KEYDOWN: HandleKeyDown ( wParam, lParam ); break; } }
/** ** Handle keyboard! */ local void SdlHandleKey(const SDL_keysym* code) { int icode; /* ** Convert SDL keycodes into internal keycodes. */ KeyModifiers=0; switch( (icode=code->sym) ) { case SDLK_ESCAPE: icode='\e'; break; case SDLK_RETURN: icode='\r'; break; case SDLK_BACKSPACE: icode='\b'; break; case SDLK_TAB: icode='\t'; break; case SDLK_UP: icode=KeyCodeUp; break; case SDLK_DOWN: icode=KeyCodeDown; break; case SDLK_LEFT: icode=KeyCodeLeft; break; case SDLK_RIGHT: icode=KeyCodeRight; break; case SDLK_PAUSE: icode=KeyCodePause; break; case SDLK_F1: icode=KeyCodeF1; break; case SDLK_F2: icode=KeyCodeF2; break; case SDLK_F3: icode=KeyCodeF3; break; case SDLK_F4: icode=KeyCodeF4; break; case SDLK_F5: icode=KeyCodeF5; break; case SDLK_F6: icode=KeyCodeF6; break; case SDLK_F7: icode=KeyCodeF7; break; case SDLK_F8: icode=KeyCodeF8; break; case SDLK_F9: icode=KeyCodeF9; break; case SDLK_F10: icode=KeyCodeF10; break; case SDLK_F11: icode=KeyCodeF11; break; case SDLK_F12: icode=KeyCodeF12; break; // We need these because if you only hit a modifier key, // the *ots from SDL didn't report correct modifiers case SDLK_LSHIFT: case SDLK_RSHIFT: KeyModifiers|=ModifierShift; break; case SDLK_LCTRL: case SDLK_RCTRL: KeyModifiers|=ModifierControl; break; case SDLK_LALT: case SDLK_RALT: case SDLK_LMETA: case SDLK_RMETA: KeyModifiers|=ModifierAlt; break; case SDLK_LSUPER: case SDLK_RSUPER: KeyModifiers|=ModifierSuper; break; default: if( code->mod&(KMOD_LSHIFT|KMOD_RSHIFT) ) { if(icode <= 'z' && icode >= 'a') { icode -= 32; } } break; } if( code->mod&(KMOD_LCTRL|KMOD_RCTRL) ) { KeyModifiers|=ModifierControl; } if( code->mod&(KMOD_LSHIFT|KMOD_RSHIFT) ) { KeyModifiers|=ModifierShift; } if( code->mod&(KMOD_LALT|KMOD_RALT) ) { KeyModifiers|=ModifierAlt; } DebugLevel3("%d\n",KeyModifiers); if( HandleKeyDown(icode) ) { return; } DoBottomPanelKey(icode); }
// -------------------------------------------------------------------------------------- static pascal OSStatus windowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *junk) { #pragma unused (nextHandler, junk) OSStatus result = eventNotHandledErr; UInt32 eventClass, eventKind; WindowRef prefsWindow; Point mouseLocation, minWindowBounds; UInt32 modifiers; ControlRef listScrollBar; ListHandle iconList; Rect iconListRect; eventClass = GetEventClass(event); eventKind = GetEventKind(event); switch (eventClass) { case kEventClassWindow: GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &prefsWindow); switch (eventKind) { case kEventWindowActivated: HandleActivate(prefsWindow, true); result = noErr; break; case kEventWindowDeactivated: HandleActivate(prefsWindow, false); result = noErr; break; case kEventWindowHandleContentClick: GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mouseLocation); GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); HandleContentClick(prefsWindow, mouseLocation, (EventModifiers)modifiers); result = noErr; break; case kEventWindowGetMinimumSize: SetPt(&minWindowBounds, gPrefsWindowWidth, gPrefsWindowHeight); SetEventParameter(event, kEventParamDimensions, typeQDPoint, sizeof(Point), &minWindowBounds); result = noErr; break; case kEventWindowResizeCompleted: AdjustControls(prefsWindow); result = noErr; break; case kEventWindowClose: ClosePrefsWindow(prefsWindow); result = noErr; break; case kEventWindowDrawContent: HandleDrawContent(prefsWindow); result = noErr; break; case kEventWindowContextualMenuSelect: result = noErr; // eat contextual menu clicks break; } break; case kEventClassControl: // we need to respond to clicks in the list's scroll bar switch (eventKind) // kEventControlClick instead of kEventControlHit { // because the control click must be tracked case kEventControlClick: // with LClick instead of the default handler GetEventParameter(event, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &listScrollBar); prefsWindow = GetControlOwner(listScrollBar); GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, &iconList); if (listScrollBar == GetListVerticalScrollBar(iconList)) { GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mouseLocation); GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); HandleContentClick(prefsWindow, mouseLocation, (EventModifiers)modifiers); result = noErr; } break; } break; case kEventClassMouse: switch (eventKind) { case kEventMouseWheelMoved: GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mouseLocation); GlobalToLocal(&mouseLocation); GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &prefsWindow); GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, &iconList); GetListViewBounds(iconList, &iconListRect); iconListRect.right += kScrollBarWidth; if (PtInRect(mouseLocation, &iconListRect)) { EventMouseWheelAxis axis; long mouseWheelDelta; SInt16 pixelDepth; Boolean isColorDevice; GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &axis); GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(long), NULL, &mouseWheelDelta); GetWindowDeviceDepthAndColor(prefsWindow, &pixelDepth, &isColorDevice); SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice); // LScroll draws the newly visible cells immediately if (axis == kEventMouseWheelAxisX) // (no update event) LScroll(-mouseWheelDelta, 0, iconList); else // axis == kEventMouseWheelAxisY LScroll(0, -mouseWheelDelta, iconList); result = noErr; } break; } break; case kEventClassTextInput: switch (eventKind) { case kEventTextInputUnicodeForKeyEvent: prefsWindow = FrontNonFloatingWindow(); if (prefsWindow != NULL) { EventRef keyboardEvent; UInt32 keyCode; GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL, sizeof(EventRef), NULL, &keyboardEvent); GetEventParameter(keyboardEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode); HandleKeyDown((char)keyCode, prefsWindow); result = noErr; } break; } break; } return result; } // windowEventHandler