本文整理汇总了C++中KeyboardEvent::keyIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyboardEvent::keyIdentifier方法的具体用法?C++ KeyboardEvent::keyIdentifier怎么用?C++ KeyboardEvent::keyIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyboardEvent
的用法示例。
在下文中一共展示了KeyboardEvent::keyIdentifier方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event)
{
if (event.type() == EventTypeNames::keydown)
type = KeyDown;
else if (event.type() == EventTypeNames::keyup)
type = WebInputEvent::KeyUp;
else if (event.type() == EventTypeNames::keypress)
type = WebInputEvent::Char;
else
return; // Skip all other keyboard events.
modifiers = event.modifiers();
timeStampSeconds = event.platformTimeStamp();
windowsKeyCode = event.keyCode();
// The platform keyevent does not exist if the event was created using
// initKeyboardEvent.
if (!event.keyEvent())
return;
nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode();
domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code());
domKey = Platform::current()->domKeyEnumFromString(event.keyEvent()->key());
unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), static_cast<unsigned>(textLengthCap));
for (unsigned i = 0; i < numberOfCharacters; ++i) {
text[i] = event.keyEvent()->text()[i];
unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i];
}
memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentifier().length());
}
示例2: if
WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event)
{
if (event.type() == EventTypeNames::keydown)
type = KeyDown;
else if (event.type() == EventTypeNames::keyup)
type = WebInputEvent::KeyUp;
else if (event.type() == EventTypeNames::keypress)
type = WebInputEvent::Char;
else
return; // Skip all other keyboard events.
modifiers = getWebInputModifiers(event);
if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_NUMPAD)
modifiers |= WebInputEvent::IsKeyPad;
else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_LEFT)
modifiers |= WebInputEvent::IsLeft;
else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_RIGHT)
modifiers |= WebInputEvent::IsRight;
timeStampSeconds = event.timeStamp() / millisPerSecond;
windowsKeyCode = event.keyCode();
// The platform keyevent does not exist if the event was created using
// initKeyboardEvent.
if (!event.keyEvent())
return;
nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode();
unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), static_cast<unsigned>(textLengthCap));
for (unsigned i = 0; i < numberOfCharacters; ++i) {
text[i] = event.keyEvent()->text()[i];
unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i];
}
memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentifier().length());
}
示例3: defaultEventHandler
void MediaDocument::defaultEventHandler(Event* event)
{
// Match the default Quicktime plugin behavior to allow
// clicking and double-clicking to pause and play the media.
Node* targetNode = event->target()->toNode();
if (!targetNode)
return;
HTMLVideoElement* video = descendentVideoElement(targetNode);
if (!video)
return;
if (event->type() == eventNames().clickEvent) {
if (!video->canPlay()) {
video->pause(event->fromUserGesture());
event->setDefaultHandled();
}
} else if (event->type() == eventNames().dblclickEvent) {
if (video->canPlay()) {
video->play(event->fromUserGesture());
event->setDefaultHandled();
}
} else if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent()) {
KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
if (keyboardEvent->keyIdentifier() == "U+0020") { // space
if (video->paused()) {
if (video->canPlay())
video->play(event->fromUserGesture());
} else
video->pause(event->fromUserGesture());
event->setDefaultHandled();
}
}
}
示例4: handleKeyupEvent
void CheckboxInputType::handleKeyupEvent(KeyboardEvent& event)
{
const String& key = event.keyIdentifier();
if (key != "U+0020")
return;
dispatchSimulatedClickIfActive(event);
}
示例5: defaultEventHandler
void SVGAElement::defaultEventHandler(Event* evt)
{
if (isLink() && (evt->type() == clickEvent || (evt->type() == keydownEvent && focused()))) {
MouseEvent* e = 0;
if (evt->type() == clickEvent && evt->isMouseEvent())
e = static_cast<MouseEvent*>(evt);
KeyboardEvent* k = 0;
if (evt->type() == keydownEvent && evt->isKeyboardEvent())
k = static_cast<KeyboardEvent*>(evt);
if (e && e->button() == RightButton) {
SVGStyledTransformableElement::defaultEventHandler(evt);
return;
}
if (k) {
if (k->keyIdentifier() != "Enter") {
SVGStyledTransformableElement::defaultEventHandler(evt);
return;
}
evt->setDefaultHandled();
dispatchSimulatedClick(evt);
return;
}
String target = this->target();
if (e && e->button() == MiddleButton)
target = "_blank";
else if (target.isEmpty()) // if target is empty, default to "_self" or use xlink:target if set
target = (getAttribute(XLinkNames::showAttr) == "new") ? "_blank" : "_self";
if (!evt->defaultPrevented()) {
String url = parseURL(href());
#if ENABLE(SVG_ANIMATION)
if (url.startsWith("#")) {
Element* targetElement = document()->getElementById(url.substring(1));
if (SVGSMILElement::isSMILElement(targetElement)) {
SVGSMILElement* timed = static_cast<SVGSMILElement*>(targetElement);
timed->beginByLinkActivation();
evt->setDefaultHandled();
SVGStyledTransformableElement::defaultEventHandler(evt);
return;
}
}
#endif
if (document()->frame())
document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, true);
}
evt->setDefaultHandled();
}
SVGStyledTransformableElement::defaultEventHandler(evt);
}
示例6: defaultEventHandler
void MediaDocument::defaultEventHandler(Event* event)
{
#if !(PLATFORM(BLACKBERRY) && OS(QNX))
// Match the default Quicktime plugin behavior to allow
// clicking and double-clicking to pause and play the media.
Node* targetNode = event->target()->toNode();
if (targetNode && targetNode->hasTagName(videoTag)) {
HTMLVideoElement* video = static_cast<HTMLVideoElement*>(targetNode);
if (event->type() == eventNames().clickEvent) {
if (!video->canPlay()) {
video->pause(event->fromUserGesture());
event->setDefaultHandled();
}
} else if (event->type() == eventNames().dblclickEvent) {
if (video->canPlay()) {
video->play(event->fromUserGesture());
event->setDefaultHandled();
}
}
}
if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent()) {
HTMLVideoElement* video = 0;
if (targetNode) {
if (targetNode->hasTagName(videoTag))
video = static_cast<HTMLVideoElement*>(targetNode);
else {
RefPtr<NodeList> nodeList = targetNode->getElementsByTagName("video");
if (nodeList.get()->length() > 0)
video = static_cast<HTMLVideoElement*>(nodeList.get()->item(0));
}
}
if (video) {
KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
if (keyboardEvent->keyIdentifier() == "U+0020") { // space
if (video->paused()) {
if (video->canPlay())
video->play(event->fromUserGesture());
} else
video->pause(event->fromUserGesture());
event->setDefaultHandled();
}
}
}
#endif
}
示例7: defaultEventHandler
void MediaDocument::defaultEventHandler(Event* event)
{
// Match the default Quicktime plugin behavior to allow
// clicking and double-clicking to pause and play the media.
Node* targetNode = event->target()->toNode();
if (!targetNode)
return;
if (HTMLVideoElement* video = ancestorVideoElement(targetNode)) {
if (event->type() == eventNames().clickEvent) {
if (!video->canPlay()) {
video->pause();
event->setDefaultHandled();
}
} else if (event->type() == eventNames().dblclickEvent) {
if (video->canPlay()) {
video->play();
event->setDefaultHandled();
}
}
}
if (!targetNode->isContainerNode())
return;
ContainerNode& targetContainer = toContainerNode(*targetNode);
if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent()) {
HTMLVideoElement* video = descendentVideoElement(targetContainer);
if (!video)
return;
KeyboardEvent* keyboardEvent = toKeyboardEvent(event);
if (keyboardEvent->keyIdentifier() == "U+0020") { // space
if (video->paused()) {
if (video->canPlay())
video->play();
} else
video->pause();
event->setDefaultHandled();
}
}
}
示例8: defaultEventHandler
void WMLAElement::defaultEventHandler(Event* event)
{
if (isLink() && (event->type() == eventNames().clickEvent || (event->type() == eventNames().keydownEvent && focused()))) {
MouseEvent* e = 0;
if (event->type() == eventNames().clickEvent && event->isMouseEvent())
e = static_cast<MouseEvent*>(event);
KeyboardEvent* k = 0;
if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent())
k = static_cast<KeyboardEvent*>(event);
if (e && e->button() == RightButton) {
WMLElement::defaultEventHandler(event);
return;
}
if (k) {
if (k->keyIdentifier() != "Enter") {
WMLElement::defaultEventHandler(event);
return;
}
event->setDefaultHandled();
dispatchSimulatedClick(event);
return;
}
if (!event->defaultPrevented() && document()->frame()) {
KURL url = document()->completeURL(parseURL(getAttribute(HTMLNames::hrefAttr)));
document()->frame()->loader()->urlSelected(url, target(), event, false, true);
}
event->setDefaultHandled();
}
WMLElement::defaultEventHandler(event);
}
示例9: getValueProperty
JSValue* JSKeyboardEvent::getValueProperty(ExecState* exec, int token) const
{
switch (token) {
case KeyIdentifierAttrNum: {
KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl());
return jsString(exec, imp->keyIdentifier());
}
case KeyLocationAttrNum: {
KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl());
return jsNumber(exec, imp->keyLocation());
}
case CtrlKeyAttrNum: {
KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl());
return jsBoolean(imp->ctrlKey());
}
case ShiftKeyAttrNum: {
KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl());
return jsBoolean(imp->shiftKey());
}
case AltKeyAttrNum: {
KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl());
return jsBoolean(imp->altKey());
}
case MetaKeyAttrNum: {
KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl());
return jsBoolean(imp->metaKey());
}
case AltGraphKeyAttrNum: {
KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl());
return jsBoolean(imp->altGraphKey());
}
case ConstructorAttrNum:
return getConstructor(exec);
}
return 0;
}
示例10: defaultEventHandler
void HTMLAnchorElement::defaultEventHandler(Event* evt)
{
// React on clicks and on keypresses.
// Don't make this KEYUP_EVENT again, it makes khtml follow links it shouldn't,
// when pressing Enter in the combo.
if (isLink() && (evt->type() == eventNames().clickEvent || (evt->type() == eventNames().keydownEvent && focused()))) {
MouseEvent* e = 0;
if (evt->type() == eventNames().clickEvent && evt->isMouseEvent())
e = static_cast<MouseEvent*>(evt);
KeyboardEvent* k = 0;
if (evt->type() == eventNames().keydownEvent && evt->isKeyboardEvent())
k = static_cast<KeyboardEvent*>(evt);
if (e && e->button() == RightButton) {
HTMLElement::defaultEventHandler(evt);
return;
}
// If the link is editable, then we need to check the settings to see whether or not to follow the link
if (isContentEditable()) {
EditableLinkBehavior editableLinkBehavior = EditableLinkDefaultBehavior;
if (Settings* settings = document()->settings())
editableLinkBehavior = settings->editableLinkBehavior();
switch (editableLinkBehavior) {
// Always follow the link (Safari 2.0 behavior)
default:
case EditableLinkDefaultBehavior:
case EditableLinkAlwaysLive:
break;
case EditableLinkNeverLive:
HTMLElement::defaultEventHandler(evt);
return;
// If the selection prior to clicking on this link resided in the same editable block as this link,
// and the shift key isn't pressed, we don't want to follow the link
case EditableLinkLiveWhenNotFocused:
if (e && !e->shiftKey() && m_rootEditableElementForSelectionOnMouseDown == rootEditableElement()) {
HTMLElement::defaultEventHandler(evt);
return;
}
break;
// Only follow the link if the shift key is down (WinIE/Firefox behavior)
case EditableLinkOnlyLiveWithShiftKey:
if (e && !e->shiftKey()) {
HTMLElement::defaultEventHandler(evt);
return;
}
break;
}
}
if (k) {
if (k->keyIdentifier() != "Enter") {
HTMLElement::defaultEventHandler(evt);
return;
}
evt->setDefaultHandled();
dispatchSimulatedClick(evt);
return;
}
String url = parseURL(getAttribute(hrefAttr));
ASSERT(evt->target());
ASSERT(evt->target()->toNode());
if (evt->target()->toNode()->hasTagName(imgTag)) {
HTMLImageElement* img = static_cast<HTMLImageElement*>(evt->target()->toNode());
if (img && img->isServerMap()) {
RenderImage* r = static_cast<RenderImage*>(img->renderer());
if (r && e) {
// FIXME: broken with transforms
FloatPoint absPos = r->localToAbsolute();
int x = e->pageX() - absPos.x();
int y = e->pageY() - absPos.y();
url += "?";
url += String::number(x);
url += ",";
url += String::number(y);
} else {
evt->setDefaultHandled();
HTMLElement::defaultEventHandler(evt);
return;
}
}
}
if (!evt->defaultPrevented() && document()->frame())
document()->frame()->loader()->urlSelected(document()->completeURL(url), getAttribute(targetAttr), evt, false, false, true);
evt->setDefaultHandled();
} else if (isLink() && isContentEditable()) {
// This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
// for the LiveWhenNotFocused editable link behavior
if (evt->type() == eventNames().mousedownEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() != RightButton && document()->frame() && document()->frame()->selection()) {
MouseEvent* e = static_cast<MouseEvent*>(evt);
//.........这里部分代码省略.........