XP_Bool LM_EventCaptureCheck(MWContext * context, uint32 current_event) { if (context->event_bit & current_event) return TRUE; if (context->grid_parent) return LM_EventCaptureCheck(context->grid_parent, current_event); return FALSE; }
// // If the user has hit return load the url // Otherwise pass the key on to the base library // void CNetscapeEdit::OnChar(UINT nChar, UINT nCnt, UINT nFlags) { BOOL bJsWantsEvent = m_Form->event_handler_present || LM_EventCaptureCheck(m_Context, EVENT_KEYDOWN | EVENT_KEYUP | EVENT_KEYPRESS); // Check if we generated this event. If so, the base. If not, call JS if (m_callBase || !bJsWantsEvent) { if(nChar == '\r') { // the user hit return #ifdef DEBUG if(!m_bOnCreateCalled) { TRACE("Bug 88020 still present\n"); #if defined (DEBUG_blythe) || defined(DEBUG_ftang) || defined(DEBUG_bstell) || defined(DEBUG_nhotta) || defined(DEBUG_jliu) ASSERT(0); #endif } #endif if(m_Submit) { // if we are the only element, return == submit // if the text is different throw out the old text and add the // new text into the layout structure UpdateAndCheckForChange(); // we are about to submit so tell libmocha about it first // do the submit in our closure if libmocha says its OK JSEvent *event; event = XP_NEW_ZAP(JSEvent); event->type = EVENT_SUBMIT; event->layer_id = m_Form->layer_id; ET_SendEvent(m_Context, (LO_Element *)m_Form, event, edit_submit_closure, this); return; } else { // we aren't auto-submitting, but the user still hit return // they prolly mean that we should check to see if we should // send a change event if(!(GetStyle() & ES_MULTILINE)) UpdateAndCheckForChange(); } } // wasn't the return key //#ifdef NO_TAB_NAVIGATION /* // let the CGenericView to handle the Tab, to step through Form elements // and links, even links inside a form. if(nChar == VK_TAB) { // if the high order bit is set (i.e. its negative) the shift // key is being held down BOOL bShift = GetKeyState(VK_SHIFT) < 0 ? TRUE : FALSE; // Determine our form element. if(m_Context) { CFormElement *pMe = CFormElement::GetFormElement(ABSTRACTCX(m_Context), m_Form); if(pMe) { // We're handling tabbing between form elements. pMe->Tab(bShift); return; } } } CEdit::OnChar(nChar, nCnt, nFlags); */ //#endif /* NO_TAB_NAVIGATION */ CEdit::OnChar(nChar, nCnt, nFlags); //If m_callBase is set, this event is a callback from a JS event and //we have to update the value of the edit field to reflect new values. if (bJsWantsEvent) { UpdateEditField(); } return; } // Give the event to JS. They'll call the base when they get back. // // Grab key events for this layer's parent. CL_GrabKeyEvents(m_Context->compositor, CL_GetLayerParent(m_Form->layer)); /* * If there's a compositor and someone has keyboard focus. * Note that if noone has event focus, we don't really need * to dispatch the event. */ if (m_Context->compositor && !CL_IsKeyEventGrabber(m_Context->compositor, NULL)) { CL_Event event; fe_EventStruct fe_event; fe_event.fe_modifiers = nCnt; fe_event.nChar = nChar; fe_event.uFlags = nFlags; fe_event.x = 1; event.type = CL_EVENT_KEY_DOWN; event.which = nChar; event.fe_event = (void *)&fe_event; event.fe_event_size = sizeof(fe_EventStruct); event.modifiers = (GetKeyState(VK_SHIFT) < 0 ? EVENT_SHIFT_MASK : 0) | (GetKeyState(VK_CONTROL) < 0 ? EVENT_CONTROL_MASK : 0) | (GetKeyState(VK_MENU) < 0 ? EVENT_ALT_MASK : 0); event.x = CL_GetLayerXOrigin(m_Form->layer); event.y = CL_GetLayerYOrigin(m_Form->layer); event.data = nFlags>>14 & 1;//Bit represeting key repetition CL_DispatchEvent(m_Context->compositor, &event); }