void DateTimeNumericFieldElement::handleKeyboardEvent(KeyboardEvent* keyboardEvent) { ASSERT(!isDisabled()); if (keyboardEvent->type() != EventTypeNames::keypress) return; UChar charCode = static_cast<UChar>(keyboardEvent->charCode()); String number = localeForOwner().convertFromLocalizedNumber(String(&charCode, 1)); const int digit = number[0] - '0'; if (digit < 0 || digit > 9) return; DOMTimeStamp delta = keyboardEvent->timeStamp() - m_lastDigitCharTime; m_lastDigitCharTime = keyboardEvent->timeStamp(); if (delta > typeAheadTimeout) m_typeAheadBuffer.clear(); m_typeAheadBuffer.append(number); int newValue = typeAheadValue(); if (newValue >= m_hardLimits.minimum) setValueAsInteger(newValue, DispatchEvent); else { m_hasValue = false; updateVisibleValue(DispatchEvent); } if (m_typeAheadBuffer.length() >= DateTimeNumericFieldElement::formatValue(m_range.maximum).length() || newValue * 10 > m_range.maximum) focusOnNextField(); keyboardEvent->setDefaultHandled(); }
void DateTimeSymbolicFieldElement::setEmptyValue(EventBehavior eventBehavior) { if (isDisabled()) return; m_selectedIndex = invalidIndex; updateVisibleValue(eventBehavior); }
void DateTimeNumericFieldElement::setValueAsInteger(int value, EventBehavior eventBehavior) { m_value = clampValue(value); m_hasValue = true; updateVisibleValue(eventBehavior); m_lastDigitCharTime = 0; }
void DateTimeNumericFieldElement::setValueAsInteger( int value, EventBehavior eventBehavior) { m_value = m_hardLimits.clampValue(value); m_hasValue = true; updateVisibleValue(eventBehavior); }
void DateTimeNumericFieldElement::handleKeyboardEvent(KeyboardEvent* keyboardEvent) { ASSERT(!isDisabled()); if (keyboardEvent->type() != EventTypeNames::keypress) return; UChar charCode = static_cast<UChar>(keyboardEvent->charCode()); String number = localeForOwner().convertFromLocalizedNumber(String(&charCode, 1)); const int digit = number[0] - '0'; if (digit < 0 || digit > 9) return; unsigned maximumLength = DateTimeNumericFieldElement::formatValue(m_range.maximum).length(); if (m_typeAheadBuffer.length() >= maximumLength) { String current = m_typeAheadBuffer.toString(); m_typeAheadBuffer.clear(); unsigned desiredLength = maximumLength - 1; m_typeAheadBuffer.append(current, current.length() - desiredLength, desiredLength); } m_typeAheadBuffer.append(number); int newValue = typeAheadValue(); if (newValue >= m_hardLimits.minimum) setValueAsInteger(newValue, DispatchEvent); else { m_hasValue = false; updateVisibleValue(DispatchEvent); } if (m_typeAheadBuffer.length() >= maximumLength || newValue * 10 > m_range.maximum) focusOnNextField(); keyboardEvent->setDefaultHandled(); }
void DateTimeSymbolicFieldElement::stepUp() { if (hasValue()) { if (!indexIsInRange(++m_selectedIndex)) m_selectedIndex = m_minimumIndex; } else m_selectedIndex = m_minimumIndex; updateVisibleValue(DispatchEvent); }
void DateTimeNumericFieldElement::setEmptyValue(EventBehavior eventBehavior) { if (isDisabled()) return; m_hasValue = false; m_value = 0; m_typeAheadBuffer.clear(); updateVisibleValue(eventBehavior); }
void DateTimeNumericFieldElement::setEmptyValue(EventBehavior eventBehavior) { m_lastDigitCharTime = 0; if (isReadOnly()) return; m_hasValue = false; m_value = 0; updateVisibleValue(eventBehavior); }
void DateTimeNumericFieldElement::setEmptyValue(const DateComponents& dateForReadOnlyField, EventBehavior eventBehavior) { m_lastDigitCharTime = 0; if (isReadOnly()) { setValueAsDate(dateForReadOnlyField); return; } m_hasValue = false; m_value = 0; updateVisibleValue(eventBehavior); }
void DateTimeSymbolicFieldElement::setValueAsInteger(int newSelectedIndex, EventBehavior eventBehavior) { m_selectedIndex = std::max(0, std::min(newSelectedIndex, static_cast<int>(m_symbols.size() - 1))); updateVisibleValue(eventBehavior); }