//	WChatInput::QObject::event()
bool
WChatInput::event(QEvent * pEvent)
	{
	QEvent::Type eEventType = pEvent->type();
	//MessageLog_AppendTextFormatSev(eSeverityNoise, "WChatInput::event(type=$i)\n", eEventType);
	if (eEventType == QEvent::KeyPress)
		{
		QKeyEvent * pEventKey = static_cast<QKeyEvent *>(pEvent);
		const Qt::Key eKey = (Qt::Key)pEventKey->key();
		//MessageLog_AppendTextFormatSev(eSeverityNoise, "WChatInput::event(QEvent::KeyPress, key=0x$p, modifiers=$x)\n", eKey, pEventKey->modifiers());
		if ((eKey & d_kmKeyboardSpecialKeys) == 0)
			{
			// The user typed something other than a special key
			m_ttcBeforeChatStatePaused = d_ttcChatStateEventPaused;
			if (m_tidChatStateComposing == d_zNA)
				{
				m_tidChatStateComposing = startTimer(d_ttiChatState);	// Create a timer to determine when the user 'stopped' typing
				m_pwLayoutChatLog->Socket_WriteXmlChatState(eChatState_zComposing);
				}
			}
		if ((pEventKey->modifiers() & ~Qt::KeypadModifier) == Qt::NoModifier)
			{
			ITreeItemChatLogEvents * pContactOrGroup = m_pwLayoutChatLog->PGetContactOrGroup_NZ();
			pContactOrGroup->TreeItem_IconUpdateOnMessagesRead();	// Any key pressed in the message input assumes the user read the message history
			//m_pwLayoutChatLog->TreeItem_UpdateIconMessageRead();	// Any key pressed in the message input assumes the user read the message history
			if (eKey == Qt::Key_Enter || eKey == Qt::Key_Return)
				{
				EUserCommand eUserCommand = eUserCommand_ComposingStopped;	// Pretend the text message was sent
				CStr strText = *this;
				if (!strText.FIsEmptyString())
					{
					m_strTextLastWritten = strText;
					if (m_pEventEdit == NULL)
						eUserCommand = pContactOrGroup->Xmpp_EParseUserCommandAndSendEvents(IN_MOD_INV strText);	// This is the typical case of a new message
					else
						{
						// The user was editing an existing message
						m_pEventEdit->EventUpdateMessageText(strText, INOUT m_pwLayoutChatLog);
						m_pEventEdit = NULL;
						}
					ChatStateComposingCancelTimer((BOOL)eUserCommand);	// After sending a message, cancel (reset) the timer to, so a new 'composing' notification will be sent when the user starts typing again. BTW, there is no need to send a 'pause' command since receiving a text message automatically implies a pause.
					} // if

				if (eUserCommand != eUserCommand_Error)
					{
					clear();	// Clear the chat text
					setCurrentCharFormat(QTextCharFormat());
					}
				return true;
				} // if (enter)
			if (eKey == Qt::Key_Up)
				{
				// Set the previous text if there is notning in the edit box
				CStr strText = *this;
				if (strText.FIsEmptyString())
					{
					//EditEventText(pContactOrGroup->Vault_PGetEventLastMessageSentEditable_YZ());
					m_pEventEdit = pContactOrGroup->Vault_PFindEventLastMessageTextSentMatchingText(IN m_strTextLastWritten);
					if (m_pEventEdit != NULL)
						{
						MessageLog_AppendTextFormatSev(eSeverityNoise, "Editing Event ID $t\n", m_pEventEdit->m_tsEventID);
						}
					setPlainText(m_strTextLastWritten);
					moveCursor(QTextCursor::End);
					return true;
					}
				}
			if (eKey == Qt::Key_Escape)
				{
				m_pEventEdit = NULL;
				clear();	// Clear the chat text
				return TRUE;
				}
			} // if
		}
	else if (eEventType == QEvent::FocusIn)
		{
		//m_pwLayoutChatLog->OnEventFocusIn();
		m_pwLayoutChatLog->PGetContactOrGroup_NZ()->TreeItem_IconUpdateOnMessagesRead();
		}
	return WEditTextArea::event(pEvent);
	} // event()