Example #1
0
HTMLEventStatus HTMLInputReset::DefaultEvent(HTMLEvent *pEvent)
{
HTMLEvent e;
HTMLForm *pForm = Form();
HTMLDocument *pDoc = GetDocument();
int x = pEvent->data.position.x, y = pEvent->data.position.y;
WebKey key;

    WEBC_DEBUG_ReceiveEvent(this, pEvent);
	switch (pEvent->type)
	{
		case HTML_EVENT_CLICK:
			if (pForm)
			{
				e.type = HTML_EVENT_RESET;
				e.data.position.x = x;
				e.data.position.y = y;
				e.elem = (HELEMENT_HANDLE)this;

				return (pForm->Event(&e));
			}
			return (HTML_EVENT_STATUS_DONE);

		case HTML_EVENT_KEYDOWN:
		{
			HTMLEventStatus retval = DefaultInputKeyHandler(pEvent);
			if (retval != HTML_EVENT_STATUS_CONTINUE)
			{
				return (retval);
			}
			break;
		}

		case HTML_EVENT_KEYPRESS:
			key = pEvent->data.key;
			if (pForm && key ==  '\r')
			{
				e.type = HTML_EVENT_RESET;
				e.data.position.x = x;
				e.data.position.y = y;
				e.elem = (HELEMENT_HANDLE)this;

				HTMLEventStatus status = pForm->Event(&e);
				if (status == HTML_EVENT_STATUS_HALT)
				{
					return (status);
				}
				return (HTML_EVENT_STATUS_CONTINUE);
			}
			break;

		default:
			// ignore other event types
			break;
	}

	return (HTMLInputButton::DefaultEvent(pEvent));
}
Example #2
0
HTMLEventStatus HTMLInputPassword::DefaultEvent(HTMLEvent *pEvent) // tbd
{
	WEBC_UINT8 onlyBox = 1;
	WEBC_UINT8 hasSubmit = 0;
	HTMLElement *pElem = 0;
	HTMLInput *pSubmit = 0;
	vector_iterator it;
    WEBC_DEBUG_ReceiveEvent(this, pEvent);
	switch (pEvent->type)
	{
		case HTML_EVENT_CHANGE:
			break;

		case HTML_EVENT_EDIT:
		{
			HTMLForm *pForm = Form();
			if (pForm)
			{
				pElem = (HTMLElement*)ObjectListGetFirst(pForm->GetFieldVector(), &it);
				while (pElem)
				{
					if ( (pElem->Type() == HTML_EDIT_STR_ELEMENT ||
						pElem->Type() == HTML_EDITBOX_ELEMENT)
						&& pElem != this)
					{
						onlyBox = 0;
						break;
					}
					if (pElem->Type() == HTML_BUTTON_ELEMENT
						&& !hasSubmit)
					{
						hasSubmit = 1;
						pSubmit = (HTMLInput *)pElem;
					}
					pElem = (HTMLElement*)ObjectListGetNext(&it);
				}
				if (pSubmit && onlyBox)
				{
					HTMLEvent e;
					e.type = HTML_EVENT_SUBMIT;
					e.data.position.x = pEvent->data.position.x;
					e.data.position.y = pEvent->data.position.y;
					e.elem = (HELEMENT_HANDLE)pSubmit;

					return (pForm->Event(&e));
				}
			}
			break;
		}

		case HTML_EVENT_FOCUS:
		{
			HTMLSetFlagFinder f(HELEM_FLAG_HAS_FOCUS, 1);
			FindElement(&f);
			SetFlag(HINPUT_FLAG_ACTIVE);
			Update(0,0);
			break;
		}

		case HTML_EVENT_UNFOCUS:
		{
			HTMLSetFlagFinder f(HELEM_FLAG_HAS_FOCUS, 0);
			FindElement(&f);
			ClearFlag(HINPUT_FLAG_ACTIVE);
			Update(0,0);
			break;
		}

		case HTML_EVENT_KEYDOWN:
		{
			HTMLEventStatus retval = DefaultInputKeyHandler(pEvent);
			if (retval != HTML_EVENT_STATUS_CONTINUE)
			{
				return (retval);
			}

			switch (pEvent->data.key)
			{
				case WGK_LNDN:
				case WGK_LNUP:
				case WGK_LEFT:
				case WGK_RIGHT:
					pEvent->flags |= HTML_EVENT_FLAG_CANCEL_BUBBLE;
					break;
			}
			break;
		}

		default:
			break;
	}

	return (HTMLInput::DefaultEvent(pEvent));
}