bool NewProjectDialog::MessageReceived(EMListenerRepository* p_opSender, uint32 p_vMessage) { float vX; float vY; bool vButtonOne; bool vButtonTwo; bool vButtonThree; switch(p_vMessage) { case EM_DRAW: Draw(m_opView -> GetClippingRect()); return true; case EM_MOUSE_DOWN: m_opView -> GetMouse(vX, vY, vButtonOne, vButtonTwo, vButtonThree); MouseDown(vX, vY, vButtonOne, vButtonTwo, vButtonThree); return true; case EM_MOUSE_MOVED: m_opView -> GetMouse(vX, vY, vButtonOne, vButtonTwo, vButtonThree); MouseMoved(vX, vY, vButtonOne, vButtonTwo, vButtonThree); return true; case EM_MOUSE_UP: m_opView -> GetMouse(vX, vY, vButtonOne, vButtonTwo, vButtonThree); MouseUp(vX, vY); return true; case EM_QUIT_REQUESTED: case MESSAGE_BUTTON_CANCEL: if(m_opWindow -> Lock()) { m_opWindow -> Hide(); m_opWindow -> Unlock(); } case MESSAGE_VIDEO_FORMAT_CHANGED: { //;//cout_commented_out_4_release << "MESSAGE_VIDEO_FORMAT_CHANGED" << endl; if(m_opWindow -> Lock()) { int32 vIndex = m_oValueBoxVideoFormat.GetValueIndex(); // This is a hack, well live with it switch(vIndex) { case 0: m_opTextControlWidth -> SetText("320"); m_opTextControlHeight -> SetText("240"); m_opTextControlFps -> SetText("15"); break; case 1: m_opTextControlWidth -> SetText("720"); m_opTextControlHeight -> SetText("480"); m_opTextControlFps -> SetText("29.97"); break; case 2: m_opTextControlWidth -> SetText("720"); m_opTextControlHeight -> SetText("486"); m_opTextControlFps -> SetText("29.97"); break; case 3: m_opTextControlWidth -> SetText("640"); m_opTextControlHeight -> SetText("480"); m_opTextControlFps -> SetText("29.97"); break; case 4: m_opTextControlWidth -> SetText("352"); m_opTextControlHeight -> SetText("240"); m_opTextControlFps -> SetText("29.97"); break; case 5: m_opTextControlWidth -> SetText("720"); m_opTextControlHeight -> SetText("576"); m_opTextControlFps -> SetText("25"); break; case 6: m_opTextControlWidth -> SetText("768"); m_opTextControlHeight -> SetText("576"); m_opTextControlFps -> SetText("25"); break; case 7: m_opTextControlWidth -> SetText("352"); m_opTextControlHeight -> SetText("288"); m_opTextControlFps -> SetText("25"); break; } m_opWindow -> Unlock(); } return true; } case MESSAGE_BUTTON_OK: if(AllValuesOk()) { EMCommandRepository::Instance() -> ExecuteCommand(COMMAND_CREATE_PROJECT, this, NULL); if(m_opWindow -> Lock()) { m_opWindow -> Hide(); m_opWindow -> Unlock(); } } return true; // case EM_CREATE_PROJECT_REQUESTED: default: return false; } }
/* Main loop. 1) Stores key presses, and calls call-back functions for press/release if necessary. 2) Calls GameAction 3) Calls GameRender */ int BaseEngine::MainLoop(void) { SDL_Event event; int iKeyCode; // Main loop: loop until told not to while (m_iExitWithCode==-1) { // Render stuff m_iTick = SDL_GetTicks(); // Poll for events, and handle the ones we care about. while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: iKeyCode = event.key.keysym.sym; if ( (iKeyCode >= SDLK_FIRST) && (iKeyCode <= SDLK_LAST) ) m_pKeyStatus[iKeyCode-SDLK_FIRST] = 1; KeyDown(iKeyCode); break; case SDL_KEYUP: iKeyCode = event.key.keysym.sym; if ( (iKeyCode >= SDLK_FIRST) && (iKeyCode <= SDLK_LAST) ) { m_pKeyStatus[iKeyCode-SDLK_FIRST] = 0; } KeyUp(iKeyCode); break; case SDL_MOUSEMOTION: m_iCurrentMouseX = event.motion.x; m_iCurrentMouseY = event.motion.y; MouseMoved( event.motion.x, event.motion.y ); break; case SDL_MOUSEBUTTONDOWN: m_iMouseXClickedDown = event.button.x; m_iMouseYClickedDown = event.button.y; MouseDown( event.button.button, event.button.x, event.button.y ); break; case SDL_MOUSEBUTTONUP: m_iMouseXClickedUp = event.button.x; m_iMouseYClickedUp = event.button.y; MouseUp( event.button.button, event.button.x, event.button.y ); break; case SDL_QUIT: return 0; } } // Do any updates for movements GameAction(); // Render the screen GameRender(); } return 0; }
void PauseState::Init() { auto i = System::GetInput(); auto o = System::GetOptions(); float width = (float)o->GetScreenResolutionWidth(); float height = (float)o->GetScreenResolutionHeight(); auto c = _controller; auto a = System::GetInstance()->GetAudio(); float widthPercentOfDefault = (1.0f / 1920.0f) * width; float heightPercentOfDefault = (1.0f / 1080.0f) * height; float fontSize = 40 ; XMFLOAT4 TextColor = XMFLOAT4(41.0f / 255.0f, 127.0f / 255.0f, 185.0f / 255.0f, 1.0f); // Radiant text Entity text = _builder->CreateLabel( XMFLOAT3(width / 2.0f - 110.0f, 25.0f, 0.0f), "Game Paused", fontSize, TextColor, 250.0f, 45.0f, ""); _builder->Transform()->SetPosition(text, XMFLOAT3(width / 2.0f - _builder->Text()->GetLength(text) / 2.0f, 25.0f, 0.0f)); // Resume button Entity b1 = _builder->CreateButton( XMFLOAT3(width / 2.0f - 110.0f, height/4.0f, 0.0f), "Resume Game", fontSize, TextColor, "", []() { }); _builder->Transform()->SetPosition(b1, XMFLOAT3(width / 2.0f - _builder->Text()->GetLength(b1) / 2.0f, height / 1.5f, 0.0f)); //Main menu button Entity b5 = _builder->CreateButton( XMFLOAT3(width / 2.0f - 110.0f, height / 4.0f, 0.0f), "Main Menu", fontSize, TextColor, "", [i, a]() { a->PlaySoundEffect(L"menuclick.wav", 1); ChangeStateTo(StateChange(new MenuState())); }); _builder->Transform()->SetPosition(b5, XMFLOAT3(width / 2.0f - _builder->Text()->GetLength(b5) / 2.0f, height / 1.5f + 55.0f, 0.0f)); // Exit button Entity b2 = _builder->CreateButton( XMFLOAT3(width / 2.0f - 110.0f, height / 4.0f + 55.0f, 0.0f), "Exit to desktop", fontSize, TextColor, "", [a]() { a->PlaySoundEffect(L"menuclick.wav", 1); ExitApplication; }); _builder->Transform()->SetPosition(b2, XMFLOAT3(width / 2.0f - _builder->Text()->GetLength(b2)/2.0f, height / 1.5f + 110.0f, 0.0f)); _controller->BindEvent(b1, EventManager::EventType::LeftClick, [i, a, this, text, b1, b2, b5]() { _controller->ReleaseEntity(text); _controller->ReleaseEntity(b1); _controller->ReleaseEntity(b2); _controller->ReleaseEntity(b5); i->LockMouseToCenter(true); i->LockMouseToWindow(true); i->HideCursor(true); i->MouseUp(VK_LBUTTON); a->PlaySoundEffect(L"menuclick.wav", 1); ChangeStateTo(StateChange(_savedState,false,true,true)); _savedState = nullptr; }); _controller->BindEvent(b1, EventManager::EventType::Update, [i, a, this, text, b1, b2, b5]() { if (i->IsKeyPushed(VK_ESCAPE)) { _controller->ReleaseEntity(text); _controller->ReleaseEntity(b1); _controller->ReleaseEntity(b2); _controller->ReleaseEntity(b5); i->LockMouseToCenter(true); i->LockMouseToWindow(true); i->HideCursor(true); i->MouseUp(VK_LBUTTON); a->PlaySoundEffect(L"menuclick.wav", 1); ChangeStateTo(StateChange(_savedState, false, true, true)); _savedState = nullptr; } }); }
GUI_status InventoryWidget::MouseClick(int x, int y, int button) { return(MouseUp(x, y, button)); }
void View::MouseEvent( int what, int x, int y, unsigned int buttons ) { // Backwards, as added. lock(); for ( int i = CountChildren() - 1; i >= 0; i-- ) { View *view = ChildAt(i); if ( view->Frame().Contains( x,y ) ) { int nx = x - view->Frame().left; int ny = y - view->Frame().top; if ( GetWindow() != NULL ) GetWindow()->SetActiveView( view ); view->MouseEvent( what, nx, ny, buttons ); unlock(); return; } } unlock(); // Otherwise... switch( what ) { case MOUSE_DOWN: MouseDown( x, y, buttons ); break; case MOUSE_UP: if ( hasFlag( HAS_POPUPMENU ) == false ) { MouseUp( x, y, buttons ); break; } // Only the right mouse button. if ( m_buttons != RIGHT_MOUSE_BUTTON ) { MouseUp( x, y, buttons ); break; } if ( m_popupMenu == NULL ) m_popupMenu = Popup(); if ( m_popupMenu == NULL ) return; m_popupMenu->MoveTo( x - m_popupMenu->Frame().Width() / 2, y - m_popupMenu->Frame().Height() / 2 ); m_popupMenu->Show(); break; case MOUSE_MOVED: MouseMoved( x, y, buttons ); break; } m_buttons = buttons; }
HRESULT CWMPEventDispatch::Invoke( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo, unsigned int FAR* puArgErr ) { if (!pDispParams) return E_POINTER; if (pDispParams->cNamedArgs != 0) return DISP_E_NONAMEDARGS; HRESULT hr = DISP_E_MEMBERNOTFOUND; switch (dispIdMember) { case DISPID_WMPCOREEVENT_OPENSTATECHANGE: OpenStateChange(pDispParams->rgvarg[0].lVal /* NewState */ ); break; case DISPID_WMPCOREEVENT_PLAYSTATECHANGE: PlayStateChange(pDispParams->rgvarg[0].lVal /* NewState */); break; case DISPID_WMPCOREEVENT_AUDIOLANGUAGECHANGE: AudioLanguageChange(pDispParams->rgvarg[0].lVal /* LangID */); break; case DISPID_WMPCOREEVENT_STATUSCHANGE: StatusChange(); break; case DISPID_WMPCOREEVENT_SCRIPTCOMMAND: ScriptCommand(pDispParams->rgvarg[1].bstrVal /* scType */, pDispParams->rgvarg[0].bstrVal /* Param */ ); break; case DISPID_WMPCOREEVENT_NEWSTREAM: NewStream(); break; case DISPID_WMPCOREEVENT_DISCONNECT: Disconnect(pDispParams->rgvarg[0].lVal /* Result */ ); break; case DISPID_WMPCOREEVENT_BUFFERING: Buffering(pDispParams->rgvarg[0].boolVal /* Start */); break; case DISPID_WMPCOREEVENT_ERROR: Error(); break; case DISPID_WMPCOREEVENT_WARNING: Warning(pDispParams->rgvarg[1].lVal /* WarningType */, pDispParams->rgvarg[0].lVal /* Param */, pDispParams->rgvarg[2].bstrVal /* Description */); break; case DISPID_WMPCOREEVENT_ENDOFSTREAM: EndOfStream(pDispParams->rgvarg[0].lVal /* Result */ ); break; case DISPID_WMPCOREEVENT_POSITIONCHANGE: PositionChange(pDispParams->rgvarg[1].dblVal /* oldPosition */, pDispParams->rgvarg[0].dblVal /* newPosition */); break; case DISPID_WMPCOREEVENT_MARKERHIT: MarkerHit(pDispParams->rgvarg[0].lVal /* MarkerNum */); break; case DISPID_WMPCOREEVENT_DURATIONUNITCHANGE: DurationUnitChange(pDispParams->rgvarg[0].lVal /* NewDurationUnit */); break; case DISPID_WMPCOREEVENT_CDROMMEDIACHANGE: CdromMediaChange(pDispParams->rgvarg[0].lVal /* CdromNum */); break; case DISPID_WMPCOREEVENT_PLAYLISTCHANGE: PlaylistChange(pDispParams->rgvarg[1].pdispVal /* Playlist */, (WMPPlaylistChangeEventType) pDispParams->rgvarg[0].lVal /* change */); break; case DISPID_WMPCOREEVENT_CURRENTPLAYLISTCHANGE: CurrentPlaylistChange((WMPPlaylistChangeEventType) pDispParams->rgvarg[0].lVal /* change */); break; case DISPID_WMPCOREEVENT_CURRENTPLAYLISTITEMAVAILABLE: CurrentPlaylistItemAvailable(pDispParams->rgvarg[0].bstrVal /* bstrItemName */); break; case DISPID_WMPCOREEVENT_MEDIACHANGE: MediaChange(pDispParams->rgvarg[0].pdispVal /* Item */); break; case DISPID_WMPCOREEVENT_CURRENTMEDIAITEMAVAILABLE: CurrentMediaItemAvailable(pDispParams->rgvarg[0].bstrVal /* bstrItemName */); break; case DISPID_WMPCOREEVENT_CURRENTITEMCHANGE: CurrentItemChange(pDispParams->rgvarg[0].pdispVal /* pdispMedia */); break; case DISPID_WMPCOREEVENT_MEDIACOLLECTIONCHANGE: MediaCollectionChange(); break; case DISPID_WMPCOREEVENT_MEDIACOLLECTIONATTRIBUTESTRINGADDED: MediaCollectionAttributeStringAdded(pDispParams->rgvarg[1].bstrVal /* bstrAttribName */, pDispParams->rgvarg[0].bstrVal /* bstrAttribVal */ ); break; case DISPID_WMPCOREEVENT_MEDIACOLLECTIONATTRIBUTESTRINGREMOVED: MediaCollectionAttributeStringRemoved(pDispParams->rgvarg[1].bstrVal /* bstrAttribName */, pDispParams->rgvarg[0].bstrVal /* bstrAttribVal */ ); break; case DISPID_WMPCOREEVENT_MEDIACOLLECTIONATTRIBUTESTRINGCHANGED: MediaCollectionAttributeStringChanged(pDispParams->rgvarg[2].bstrVal /* bstrAttribName */, pDispParams->rgvarg[1].bstrVal /* bstrOldAttribVal */, pDispParams->rgvarg[0].bstrVal /* bstrNewAttribVal */); break; case DISPID_WMPCOREEVENT_PLAYLISTCOLLECTIONCHANGE: PlaylistCollectionChange(); break; case DISPID_WMPCOREEVENT_PLAYLISTCOLLECTIONPLAYLISTADDED: PlaylistCollectionPlaylistAdded(pDispParams->rgvarg[0].bstrVal /* bstrPlaylistName */ ); break; case DISPID_WMPCOREEVENT_PLAYLISTCOLLECTIONPLAYLISTREMOVED: PlaylistCollectionPlaylistRemoved(pDispParams->rgvarg[0].bstrVal /* bstrPlaylistName */ ); break; case DISPID_WMPCOREEVENT_PLAYLISTCOLLECTIONPLAYLISTSETASDELETED: PlaylistCollectionPlaylistSetAsDeleted(pDispParams->rgvarg[1].bstrVal /* bstrPlaylistName */, pDispParams->rgvarg[0].boolVal /* varfIsDeleted */); break; case DISPID_WMPCOREEVENT_MODECHANGE: ModeChange(pDispParams->rgvarg[1].bstrVal /* ModeName */, pDispParams->rgvarg[0].boolVal /* NewValue */); break; case DISPID_WMPCOREEVENT_MEDIAERROR: MediaError(pDispParams->rgvarg[0].pdispVal /* pMediaObject */); break; case DISPID_WMPCOREEVENT_OPENPLAYLISTSWITCH: OpenPlaylistSwitch(pDispParams->rgvarg[0].pdispVal /* pItem */); break; case DISPID_WMPCOREEVENT_DOMAINCHANGE: DomainChange(pDispParams->rgvarg[0].bstrVal /* strDomain */); break; case DISPID_WMPOCXEVENT_SWITCHEDTOPLAYERAPPLICATION: SwitchedToPlayerApplication(); break; case DISPID_WMPOCXEVENT_SWITCHEDTOCONTROL: SwitchedToControl(); break; case DISPID_WMPOCXEVENT_PLAYERDOCKEDSTATECHANGE: PlayerDockedStateChange(); break; case DISPID_WMPOCXEVENT_PLAYERRECONNECT: PlayerReconnect(); break; case DISPID_WMPOCXEVENT_CLICK: Click(pDispParams->rgvarg[3].iVal /* nButton */, pDispParams->rgvarg[2].iVal /* nShiftState */, pDispParams->rgvarg[1].lVal /* fX */, pDispParams->rgvarg[0].lVal /* fY */); break; case DISPID_WMPOCXEVENT_DOUBLECLICK: DoubleClick(pDispParams->rgvarg[3].iVal /* nButton */, pDispParams->rgvarg[2].iVal /* nShiftState */, pDispParams->rgvarg[1].lVal /* fX */, pDispParams->rgvarg[0].lVal /* fY */); break; case DISPID_WMPOCXEVENT_KEYDOWN: KeyDown(pDispParams->rgvarg[1].iVal /* nKeyCode */, pDispParams->rgvarg[0].iVal /* nShiftState */); break; case DISPID_WMPOCXEVENT_KEYPRESS: KeyPress(pDispParams->rgvarg[0].iVal /* nKeyAscii */); break; case DISPID_WMPOCXEVENT_KEYUP: KeyUp(pDispParams->rgvarg[1].iVal /* nKeyCode */, pDispParams->rgvarg[0].iVal /* nShiftState */); break; case DISPID_WMPOCXEVENT_MOUSEDOWN: MouseDown(pDispParams->rgvarg[3].iVal /* nButton */, pDispParams->rgvarg[2].iVal /* nShiftState */, pDispParams->rgvarg[1].lVal /* fX */, pDispParams->rgvarg[0].lVal /* fY */); break; case DISPID_WMPOCXEVENT_MOUSEMOVE: MouseMove(pDispParams->rgvarg[3].iVal /* nButton */, pDispParams->rgvarg[2].iVal /* nShiftState */, pDispParams->rgvarg[1].lVal /* fX */, pDispParams->rgvarg[0].lVal /* fY */); break; case DISPID_WMPOCXEVENT_MOUSEUP: MouseUp(pDispParams->rgvarg[3].iVal /* nButton */, pDispParams->rgvarg[2].iVal /* nShiftState */, pDispParams->rgvarg[1].lVal /* fX */, pDispParams->rgvarg[0].lVal /* fY */); break; } return( hr ); }
void MouseMouse() { unsigned char byte1 = 0, byte2 = 0, byte3 = 0; int xChange, yChange, lButton, mButton, rButton; // Disable keyboard output here, because our data reads are not atomic MouseOut(MOUSE_CONTROL, CTRL_DEACTIVATE); byte1 = MouseIn(); if(byte1==-1) { MouseOut(MOUSE_CONTROL, CTRL_CMD); MouseOut(MOUSE_DATA, CMD_RESEND); MouseOut(MOUSE_CONTROL, CTRL_DEACTIVATE); return; } byte2 = MouseIn(); byte3 = MouseIn(); // Re-enable keyboard output MouseOut(MOUSE_CONTROL, CTRL_DEACTIVATE); lButton = ((byte1 & BYTE1_LEFT) == BYTE1_LEFT); mButton = ((byte1 & BYTE1_MIDDLE) == BYTE1_MIDDLE); rButton = ((byte1 & BYTE1_RIGHT) == BYTE1_RIGHT); if(byte1 & BYTE1_SIGNX) xChange = (int)(((unsigned int)~0xFF)|(byte2 & 0xFF)); else xChange = (int)byte2; if(byte1 & BYTE1_SIGNY) yChange = (int)(((unsigned int)~0xFF)|(byte3 & 0xFF)); else yChange = (int)byte3; MouseX += xChange; MouseY -= yChange; if(MouseX < 0) MouseX = 0; if(MouseY < 0) MouseY = 0; if(MouseX >= LoaderInfo->VideoMode.ModeWidth) MouseX = LoaderInfo->VideoMode.ModeWidth - 1; if(MouseY >= LoaderInfo->VideoMode.ModeHeight) MouseY = LoaderInfo->VideoMode.ModeHeight - 1; MouseMove(MouseX, MouseY); if(lButton ^ ButtonL) if(lButton) MouseDown(0); else MouseUp(0); if(mButton ^ ButtonM) if(mButton) MouseDown(1); else MouseUp(1); if(rButton ^ ButtonR) if(rButton) MouseDown(2); else MouseUp(2); ButtonL = lButton; ButtonM = mButton; ButtonR = rButton; }
NS_IMETHODIMP EditorEventListener::HandleEvent(nsIDOMEvent* aEvent) { NS_ENSURE_TRUE(mEditorBase, NS_ERROR_FAILURE); nsCOMPtr<nsIEditor> kungFuDeathGrip = mEditorBase; Unused << kungFuDeathGrip; // mEditorBase is not referred to in this function WidgetEvent* internalEvent = aEvent->WidgetEventPtr(); // Let's handle each event with the message of the internal event of the // coming event. If the DOM event was created with improper interface, // e.g., keydown event is created with |new MouseEvent("keydown", {});|, // its message is always 0. Therefore, we can ban such strange event easy. // However, we need to handle strange "focus" and "blur" event. See the // following code of this switch statement. // NOTE: Each event handler may require specific event interface. Before // calling it, this queries the specific interface. If it would fail, // each event handler would just ignore the event. So, in this method, // you don't need to check if the QI succeeded before each call. switch (internalEvent->mMessage) { // dragenter case eDragEnter: { nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent); return DragEnter(dragEvent); } // dragover case eDragOver: { nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent); return DragOver(dragEvent); } // dragexit case eDragExit: { nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent); return DragExit(dragEvent); } // drop case eDrop: { nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent); return Drop(dragEvent); } #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH // keydown case eKeyDown: { nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent); return KeyDown(keyEvent); } // keyup case eKeyUp: { nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent); return KeyUp(keyEvent); } #endif // #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH // keypress case eKeyPress: { nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent); return KeyPress(keyEvent); } // mousedown case eMouseDown: { nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent); NS_ENSURE_TRUE(mouseEvent, NS_OK); // EditorEventListener may receive (1) all mousedown, mouseup and click // events, (2) only mousedown event or (3) only mouseup event. // mMouseDownOrUpConsumedByIME is used only for ignoring click event if // preceding mousedown and/or mouseup event is consumed by IME. // Therefore, even if case #2 or case #3 occurs, // mMouseDownOrUpConsumedByIME is true here. Therefore, we should always // overwrite it here. mMouseDownOrUpConsumedByIME = NotifyIMEOfMouseButtonEvent(mouseEvent); return mMouseDownOrUpConsumedByIME ? NS_OK : MouseDown(mouseEvent); } // mouseup case eMouseUp: { nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent); NS_ENSURE_TRUE(mouseEvent, NS_OK); // See above comment in the eMouseDown case, first. // This code assumes that case #1 is occuring. However, if case #3 may // occurs after case #2 and the mousedown is consumed, // mMouseDownOrUpConsumedByIME is true even though EditorEventListener // has not received the preceding mousedown event of this mouseup event. // So, mMouseDownOrUpConsumedByIME may be invalid here. However, // this is not a matter because mMouseDownOrUpConsumedByIME is referred // only by eMouseClick case but click event is fired only in case #1. // So, before a click event is fired, mMouseDownOrUpConsumedByIME is // always initialized in the eMouseDown case if it's referred. if (NotifyIMEOfMouseButtonEvent(mouseEvent)) { mMouseDownOrUpConsumedByIME = true; } return mMouseDownOrUpConsumedByIME ? NS_OK : MouseUp(mouseEvent); } // click case eMouseClick: { nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent); NS_ENSURE_TRUE(mouseEvent, NS_OK); // If the preceding mousedown event or mouseup event was consumed, // editor shouldn't handle this click event. if (mMouseDownOrUpConsumedByIME) { mMouseDownOrUpConsumedByIME = false; mouseEvent->AsEvent()->PreventDefault(); return NS_OK; } return MouseClick(mouseEvent); } // focus case eFocus: return Focus(aEvent); // blur case eBlur: return Blur(aEvent); // text case eCompositionChange: return HandleText(aEvent); // compositionstart case eCompositionStart: return HandleStartComposition(aEvent); // compositionend case eCompositionEnd: HandleEndComposition(aEvent); return NS_OK; default: break; } nsAutoString eventType; aEvent->GetType(eventType); // We should accept "focus" and "blur" event even if it's synthesized with // wrong interface for compatibility with older Gecko. if (eventType.EqualsLiteral("focus")) { return Focus(aEvent); } if (eventType.EqualsLiteral("blur")) { return Blur(aEvent); } #ifdef DEBUG nsPrintfCString assertMessage("Editor doesn't handle \"%s\" event " "because its internal event doesn't have proper message", NS_ConvertUTF16toUTF8(eventType).get()); NS_ASSERTION(false, assertMessage.get()); #endif return NS_OK; }