当前位置: 首页>>代码示例>>C++>>正文


C++ KeyboardEvent类代码示例

本文整理汇总了C++中KeyboardEvent的典型用法代码示例。如果您正苦于以下问题:C++ KeyboardEvent类的具体用法?C++ KeyboardEvent怎么用?C++ KeyboardEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了KeyboardEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: defaultEventHandler

void SVGAElement::defaultEventHandler(Event* evt)
{
    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) {
            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 = deprecatedParseURL(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, false, true, SendReferrer);
        }

        evt->setDefaultHandled();
    }

    SVGStyledTransformableElement::defaultEventHandler(evt);
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:55,代码来源:SVGAElement.cpp

示例2: KeyboardEvent

KeyboardEvent* EventHandler::createKeyboardEvent(const int key, const KEY_TYPE type, Action* a)
{
  EventToAction ea;
  KeyboardEvent* k = new KeyboardEvent();
  
  k->setKey(key);
  k->setType(type);
  ea.e = k;
  ea.a = a;
  m_events.push_back(ea);
  return k;
}
开发者ID:andrewh8bd,项目名称:SoftwareEngineering,代码行数:12,代码来源:eventhandler.cpp

示例3: keyReleaseEvent

    bool Play::keyReleaseEvent(const KeyboardEvent& event)
    {
        if(_isPlaying)
        {
            _synchronousKeyboard->setIsAsciiPressed(event.getAscii(), false);
            _synchronousKeyboard->setIsNonAsciiPressed(event.getNonAscii(), false);
            KeyReleaseDispatcher krVisitor( event );
            (*_currentAct)->welcome( krVisitor );
            return krVisitor.eventConsumed();
        }

        return false;
    }
开发者ID:wibus,项目名称:ExperimentalTheatre,代码行数:13,代码来源:Play.cpp

示例4: handleKeyupEvent

void CheckboxInputType::handleKeyupEvent(KeyboardEvent& event)
{
    const String& key = event.keyIdentifier();
    if (key != "U+0020")
        return;
    dispatchSimulatedClickIfActive(event);
}
开发者ID:eocanha,项目名称:webkit,代码行数:7,代码来源:CheckboxInputType.cpp

示例5: OS

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
}
开发者ID:,项目名称:,代码行数:46,代码来源:

示例6: setButtonText

void EventPropertyWidgetQt::setButtonText() {
    std::string text = eventproperty_->getEvent()->modifierNames();

    if (text != "") text.append("+");

    KeyboardEvent* keyboardEvent = dynamic_cast<KeyboardEvent*>(eventproperty_->getEvent());
    if (keyboardEvent) {
        text += std::string(1, static_cast<char>(keyboardEvent->button()));
    }

    MouseEvent* mouseEvent = dynamic_cast<MouseEvent*>(eventproperty_->getEvent());
    if (mouseEvent) {
        text += mouseEvent->buttonName();
    }

    button_->setText(QString::fromStdString(text));
}
开发者ID:sarbi127,项目名称:inviwo,代码行数:17,代码来源:eventpropertywidgetqt.cpp

示例7: keyboard_callback

 void
 keyboard_callback (const KeyboardEvent& event,
                    void* /*cookie*/)
 {
     if (event.keyUp ())
     {
         return;
     }
 }
开发者ID:Razlaw,项目名称:pcl,代码行数:9,代码来源:hdl_viewer_simple.cpp

示例8: toKeyboardEvent

void MediaDocument::defaultEventHandler(Event* event)
{
    Node* targetNode = event->target()->toNode();
    if (!targetNode)
        return;

    if (event->type() == EventTypeNames::keydown && event->isKeyboardEvent()) {
        HTMLVideoElement* video = Traversal<HTMLVideoElement>::firstWithin(*targetNode);
        if (!video)
            return;

        KeyboardEvent* keyboardEvent = toKeyboardEvent(event);
        if (keyboardEvent->key() == " " || keyboardEvent->keyCode() == VKEY_MEDIA_PLAY_PAUSE) {
            // space or media key (play/pause)
            video->togglePlayState();
            event->setDefaultHandled();
        }
    }
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:19,代码来源:MediaDocument.cpp

示例9: userMain

int userMain (int argc, char* argv[])
{
	TName producerName = "producerx";
	BoundedBuffer *buff;
	Consumer *con;
	intLock
	buff = new BoundedBuffer(atoi(argv[1]));
	N = atoi(argv[2]);
	N = N>19 ? 19 : N;
	TIME_SLICE = atoi(argv[3]);
	Producer **pro = new Producer*[N];
	KeyboardEvent* kev;
	int i;
	
	con = new Consumer(buff);
	  
	con->start();

	for (i=0; i<N; i++){
		producerName[8]='0'+i;
		pro[i] = new Producer(buff, producerName ,'0'+i, TIME_SLICE);
		pro[i]->start();
	}
  
  	kev = new KeyboardEvent(buff);
	intUnlock
	
	kev->start();
	
	for (i=0; i<N; i++){
		delete pro[i];
	}  
	delete [] pro;
	delete kev;
	delete con;

	intLock
	cout<<"Kraj userMain"<<endl;
	intUnlock
  
	
  return 0;
}
开发者ID:ntrifunovic,项目名称:ETF-OS1,代码行数:43,代码来源:user.cpp

示例10: shouldInsertCharacter

bool EditingBehavior::shouldInsertCharacter(const KeyboardEvent& event) const
{
    if (event.keyEvent()->text().length() != 1)
        return true;

    // On Gtk/Linux, it emits key events with ASCII text and ctrl on for ctrl-<x>.
    // In Webkit, EditorClient::handleKeyboardEvent in
    // WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp drop such events.
    // On Mac, it emits key events with ASCII text and meta on for Command-<x>.
    // These key events should not emit text insert event.
    // Alt key would be used to insert alternative character, so we should let
    // through. Also note that Ctrl-Alt combination equals to AltGr key which is
    // also used to insert alternative character.
    // http://code.google.com/p/chromium/issues/detail?id=10846
    // Windows sets both alt and meta are on when "Alt" key pressed.
    // http://code.google.com/p/chromium/issues/detail?id=2215
    // Also, we should not rely on an assumption that keyboards don't
    // send ASCII characters when pressing a control key on Windows,
    // which may be configured to do it so by user.
    // See also http://en.wikipedia.org/wiki/Keyboard_Layout
    // FIXME(ukai): investigate more detail for various keyboard layout.
    UChar ch = event.keyEvent()->text()[0U];

    // Don't insert null or control characters as they can result in
    // unexpected behaviour
    if (ch < ' ')
        return false;
#if !OS(WIN)
    // Don't insert ASCII character if ctrl w/o alt or meta is on.
    // On Mac, we should ignore events when meta is on (Command-<x>).
    if (ch < 0x80) {
        if (event.keyEvent()->ctrlKey() && !event.keyEvent()->altKey())
            return false;
#if OS(MACOSX)
        if (event.keyEvent()->metaKey())
            return false;
#endif
    }
#endif

    return true;
}
开发者ID:eth-srl,项目名称:BlinkER,代码行数:42,代码来源:EditingBehavior.cpp

示例11: didBlur

void DateTimeFieldElement::defaultEventHandler(Event* event)
{
    if (event->type() == eventNames().blurEvent)
        didBlur();

    if (event->type() == eventNames().focusEvent)
        didFocus();

    if (event->isKeyboardEvent()) {
        KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
        handleKeyboardEvent(keyboardEvent);
        if (keyboardEvent->defaultHandled())
            return;
        defaultKeyboardEventHandler(keyboardEvent);
        if (keyboardEvent->defaultHandled())
            return;
    }

    HTMLElement::defaultEventHandler(event);
}
开发者ID:jiezh,项目名称:h5vcc,代码行数:20,代码来源:DateTimeFieldElement.cpp

示例12: XboxManager

void	Event::SysEvent::Loop()
{
  _xbox = new XboxManager();
  _leap = new LeapManager();
  _leap->Connect();
  wait_systen();
  while (G_GameSettings && G_GameSettings->gameState != Settings::END)
    {
      if (_ogl->IsInit() && _ogl->IsClose() == false)
	{
	  _sdl = _ogl->GetContext();
	  _input = _ogl->GetInput();
	  _ogl->Lock();
	  _sdl->updateInputs(*_input);
	  _ogl->Unlock();
	  _keymanager.updateValue(*_input);
	  _xbox->Reset();
	  _xbox->Update();
	  if (G_EvDispatcher)
	    {
	      if (_keymanager.isUpdated() == true)
		{
		  G_EvDispatcher->SendEvent(new KeyboardEvent(_keymanager.getKeyboard()), COMMON);
		  KeyboardEvent	*sysev = new KeyboardEvent(_keymanager.getKeyboard());
		  sysev->SetScope(ENGINE);
		  G_EvDispatcher->SendEvent(sysev, SYS);
		}
	      if (_leap->HasUpdate())
		G_EvDispatcher->SendEvent(new LeapEvent(_leap->GetLeapData()), COMMON);
	      if (_xbox->HasUpdate())
		G_EvDispatcher->SendEvent(new XboxEvent(_xbox->GetInput(),
							_xbox->NumJoystick()),
					  COMMON);
	    }
	}
      usleep(5000);
    }
  _leap->Disconnect();
  delete _xbox;
  delete _leap;
}
开发者ID:,项目名称:,代码行数:41,代码来源:

示例13: if

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 = static_cast<KeyboardEvent*>(event);
        if (keyboardEvent->keyIdentifier() == "U+0020") { // space
            if (video->paused()) {
                if (video->canPlay())
                    video->play();
            } else
                video->pause();
            event->setDefaultHandled();
        }
    }
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:41,代码来源:MediaDocument.cpp

示例14: jsKeyboardEventPrototypeFunctionInitKeyboardEvent

JSValue* jsKeyboardEventPrototypeFunctionInitKeyboardEvent(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSKeyboardEvent::s_info))
        return throwError(exec, TypeError);
    JSKeyboardEvent* castedThisObj = static_cast<JSKeyboardEvent*>(thisValue);
    KeyboardEvent* imp = static_cast<KeyboardEvent*>(castedThisObj->impl());
    const UString& type = args[0]->toString(exec);
    bool canBubble = args[1]->toBoolean(exec);
    bool cancelable = args[2]->toBoolean(exec);
    DOMWindow* view = toDOMWindow(args[3]);
    const UString& keyIdentifier = args[4]->toString(exec);
    unsigned keyLocation = args[5]->toInt32(exec);
    bool ctrlKey = args[6]->toBoolean(exec);
    bool altKey = args[7]->toBoolean(exec);
    bool shiftKey = args[8]->toBoolean(exec);
    bool metaKey = args[9]->toBoolean(exec);
    bool altGraphKey = args[10]->toBoolean(exec);

    imp->initKeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, keyLocation, ctrlKey, altKey, shiftKey, metaKey, altGraphKey);
    return jsUndefined();
}
开发者ID:lentinic,项目名称:EAWebKit,代码行数:21,代码来源:JSKeyboardEvent.cpp

示例15: toKeyboardEvent

void DateTimeFieldElement::defaultEventHandler(Event* event)
{
    if (event->isKeyboardEvent()) {
        KeyboardEvent* keyboardEvent = toKeyboardEvent(event);
        if (!isDisabled() && !isFieldOwnerDisabled() && !isFieldOwnerReadOnly()) {
            handleKeyboardEvent(keyboardEvent);
            if (keyboardEvent->defaultHandled()) {
                if (m_fieldOwner)
                    m_fieldOwner->fieldDidChangeValueByKeyboard();
                return;
            }
        }
        defaultKeyboardEventHandler(keyboardEvent);
        if (m_fieldOwner)
            m_fieldOwner->fieldDidChangeValueByKeyboard();
        if (keyboardEvent->defaultHandled())
            return;
    }

    HTMLElement::defaultEventHandler(event);
}
开发者ID:dstockwell,项目名称:blink,代码行数:21,代码来源:DateTimeFieldElement.cpp


注:本文中的KeyboardEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。