char *keyBindingToString(CompDisplay * d, CompKeyBinding * key) { char *binding; binding = modifiersToString(d, key->modifiers); if (key->keycode != 0) { KeySym *keysym; char *keyname; int keysymsPerKeycode = 0; /* convert keycode to keysym */ keysym = XGetKeyboardMapping(d->display, key->keycode, 1, &keysymsPerKeycode); keyname = XKeysymToString(keysym[0]); XFree(keysym); if (keyname) { binding = stringAppend(binding, keyname); } else { char keyCodeStr[256]; snprintf(keyCodeStr, 256, "0x%x", key->keycode); binding = stringAppend(binding, keyCodeStr); } } return binding; }
char *buttonBindingToString(CompDisplay * d, CompButtonBinding * button) { char *binding; char buttonStr[256]; binding = modifiersToString(d, button->modifiers); snprintf(buttonStr, 256, "Button%d", button->button); binding = stringAppend(binding, buttonStr); return binding; }
void EventsDemo::describe(const Wt::WKeyEvent &e) { std::stringstream ss; ss << "Key: " << e.key() << "<br/>" << "Modifiers: " << modifiersToString(e.modifiers()) << "<br/>"; int charCode = (int)e.charCode(); if (charCode) { ss << "Char code: " << charCode << "<br/>" << "text: " << Utils::htmlEncode(e.text()) << "<br/>"; } keyEventDescription_->setText(ss.str()); }
void EventsDemo::describe(const Wt::WMouseEvent &e) { std::stringstream ss; ss << "Button: " << e.button() << "<br/>" << "Modifiers: " << modifiersToString(e.modifiers()) << "<br/>" << "Document coordinates: " << e.document() << "<br/>" << "Window coordinates: " << e.window() << "<br/>" << "Screen coordinates: " << e.screen() << "<br/>" << "Widget coordinates: " << e.widget() << "<br/>" << "DragDelta coordinates: " << e.dragDelta() << "<br/>" << "Wheel delta: " << e.wheelDelta() << "<br/>"; mouseEventDescription_->setText(ss.str()); }
char *buttonActionToString(CompDisplay * d, CompAction * action) { char *binding, *edge; char buttonStr[256]; binding = modifiersToString(d, action->button.modifiers); edge = edgeMaskToBindingString(d, action->edgeMask); if (edge) { binding = stringAppend(binding, edge); free(edge); } snprintf(buttonStr, 256, "Button%d", action->button.button); binding = stringAppend(binding, buttonStr); if (!binding) return strdup("Disabled"); return binding; }