本文整理汇总了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);
}
示例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;
}
示例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;
}
示例4: handleKeyupEvent
void CheckboxInputType::handleKeyupEvent(KeyboardEvent& event)
{
const String& key = event.keyIdentifier();
if (key != "U+0020")
return;
dispatchSimulatedClickIfActive(event);
}
示例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
}
示例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));
}
示例7: keyboard_callback
void
keyboard_callback (const KeyboardEvent& event,
void* /*cookie*/)
{
if (event.keyUp ())
{
return;
}
}
示例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();
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
}
}
示例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();
}
示例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);
}