const bool Win32NotificationWindow::createTrapWindow() { WNDCLASSEXA wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = Win32NotificationWindow::WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = GetModuleHandle(NULL); wcex.hIcon = 0; wcex.hCursor = 0; wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.lpszMenuName = 0; wcex.lpszClassName = classname; wcex.hIconSm = 0; RegisterClassExA(&wcex); hWindow = CreateWindowEx ( 0, (LPCSTR)classname, (LPCSTR)"EDO", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544, 375, HWND_DESKTOP, NULL, GetModuleHandle(NULL), NULL ); if (NULL == hWindow) { lastError = GetLastError(); return (false); } else { const KeyPress kp = KeyPress::createFromDescription (keyCodeDescription); if ( ! RegisterHotKey(hWindow, 0x0aff, kp.getModifiers().getRawFlags(), kp.getKeyCode()) ) { lastError = GetLastError(); return (false); } } return (true); }
//============================================================================== bool Joystick::keyPressed (const KeyPress& key) { if (key.isKeyCode (KeyPress::upKey)) { setValues(current_x,current_y-interval); } else if (key.isKeyCode (KeyPress::downKey)) { setValues(current_x,current_y+interval); } else if (key.isKeyCode (KeyPress::leftKey)) { setValues(current_x-interval,current_y); } else if (key.isKeyCode (KeyPress::rightKey)) { setValues(current_x+interval,current_y); } else { return Component::keyPressed (key); } return true; }
const Result ctrlr_sendKeyPressEvent (const KeyPress &keyPress) { Display *display = XOpenDisplay(0); if(display == NULL) return (Result::fail("Can't open display")); Window winRoot = XDefaultRootWindow(display); Window winFocus; int revert; if (!XGetInputFocus(display, &winFocus, &revert)) { return (Result::fail("XGetInputFocus failed")); } XKeyEvent event = createKeyEvent(display, winFocus, winRoot, true, keyPress.getKeyCode(), keyPress.getModifiers().getRawFlags()); if (XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event) == 0) { return (Result::fail("XSendEvent failed")); } event = createKeyEvent(display, winFocus, winRoot, false, keyPress.getKeyCode(), keyPress.getModifiers().getRawFlags()); if (XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event) == 0) { return (Result::fail("XSendEvent failed")); } XCloseDisplay(display); return (Result::ok()); }
//============================================================================== bool ComboBox::keyPressed (const KeyPress& key) { if (key.isKeyCode (KeyPress::upKey) || key.isKeyCode (KeyPress::leftKey)) { int index = getSelectedItemIndex() - 1; while (index >= 0 && ! selectIfEnabled (index)) --index; return true; } else if (key.isKeyCode (KeyPress::downKey) || key.isKeyCode (KeyPress::rightKey)) { int index = getSelectedItemIndex() + 1; while (index < getNumItems() && ! selectIfEnabled (index)) ++index; return true; } else if (key.isKeyCode (KeyPress::returnKey)) { showPopup(); return true; } return false; }
bool AlertWindow::keyPressed (const KeyPress& key) { for (int i = buttons.size(); --i >= 0;) { TextButton* const b = buttons.getUnchecked(i); if (b->isRegisteredForShortcut (key)) { b->triggerClick(); return true; } } if (key.isKeyCode (KeyPress::escapeKey) && escapeKeyCancels && buttons.size() == 0) { exitModalState (0); return true; } else if (key.isKeyCode (KeyPress::returnKey) && buttons.size() == 1) { buttons.getUnchecked(0)->triggerClick(); return true; } return false; }
void TestKeycode::testCreateFromSKeyInput() { KeyPress k; irr::SEvent::SKeyInput in; // Character key in.Key = irr::KEY_KEY_3; in.Char = L'3'; k = KeyPress(in); UASSERTEQ_STR(k.sym(), "KEY_KEY_3"); // Non-Character key in.Key = irr::KEY_RSHIFT; in.Char = L'\0'; k = KeyPress(in); UASSERTEQ_STR(k.sym(), "KEY_RSHIFT"); // Irrlicht-unknown key in.Key = irr::KEY_KEY_CODES_COUNT; in.Char = L'?'; k = KeyPress(in); UASSERTEQ_STR(k.sym(), "?"); // prefer_character mode in.Key = irr::KEY_COMMA; in.Char = L'G'; k = KeyPress(in, true); UASSERTEQ_STR(k.sym(), "KEY_KEY_G"); }
bool CommandTable::keyPressed(const KeyPress& k) { if (k.isKeyCode(KeyPress::deleteKey) && getSelectedRow() != -1) { bool last = getSelectedRow() == getNumRows() - 1; ((CommandTableModel*)getModel())->removeRow(static_cast<size_t>(getSelectedRow())); updateContent(); if (last) { // keep selection at the end selectRow(getNumRows() - 1); } return true; } if (k.isKeyCode(KeyPress::downKey) && getSelectedRow() != -1 && getSelectedRow() < getNumRows() - 1) { selectRow(getSelectedRow() + 1); return true; } if (k.isKeyCode(KeyPress::upKey) && getSelectedRow() > 0 && getNumRows() > 1) { selectRow(getSelectedRow() - 1); return true; } if (k.isKeyCode(KeyPress::pageUpKey) && getNumRows() > 0) { selectRow(0); return true; } if (k.isKeyCode(KeyPress::pageDownKey) && getNumRows() > 0) { selectRow(getNumRows() - 1); return true; } return false; }
//============================================================================== bool CodeEditorComponent::keyPressed (const KeyPress& key) { if (! TextEditorKeyMapper<CodeEditorComponent>::invokeKeyFunction (*this, key)) { if (key == KeyPress::tabKey || key.getTextCharacter() == '\t') { insertTabAtCaret(); } else if (key == KeyPress::returnKey) { newTransaction(); insertTextAtCaret (document.getNewLineCharacters()); } else if (key.isKeyCode (KeyPress::escapeKey)) { newTransaction(); } else if (key.getTextCharacter() >= ' ') { insertTextAtCaret (String::charToString (key.getTextCharacter())); } else { return false; } } return true; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); KeyPress *keyPress = new KeyPress(); keyPress->show(); return a.exec(); }
bool JucerDocumentEditor::keyPressed (const KeyPress& key) { if (key.isKeyCode (KeyPress::deleteKey) || key.isKeyCode (KeyPress::backspaceKey)) { IntrojucerApp::getCommandManager().invokeDirectly (StandardApplicationCommandIDs::del, true); return true; } return false; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); KeyPress window; window.resize(250, 150); window.setWindowTitle("Key press"); window.show(); return app.exec(); }
bool MainContentComponent::keyPressed (const KeyPress& key) { //[UserCode_keyPressed] -- Add your code here... if (key.getKeyCode() == 95 && key.getModifiers().isCtrlDown()) { changeGain(-1.00); } if (key.getKeyCode() == 43 && key.getModifiers().isCtrlDown()) { changeGain(+1.00); } return FALSE; // Return true if your handler uses this key event, or false to allow it to be passed-on. //[/UserCode_keyPressed] }
bool GraphComponent::keyPressed (const KeyPress& key) { if (key.isKeyCode (KeyPress::leftKey)) { for (int i = 0; i < selectedNodes.getNumSelected (); i++) { GraphNodeComponent* selected = selectedNodes.getSelectedItem (i); if (selected != inputs && selected != outputs) selected->setTopLeftPosition (selected->getX() - 1, selected->getY()); } } else if (key.isKeyCode (KeyPress::rightKey)) { for (int i = 0; i < selectedNodes.getNumSelected (); i++) { GraphNodeComponent* selected = selectedNodes.getSelectedItem (i); if (selected != inputs && selected != outputs) selected->setTopLeftPosition (selected->getX() + 1, selected->getY()); } } else if (key.isKeyCode (KeyPress::upKey)) { for (int i = 0; i < selectedNodes.getNumSelected (); i++) { GraphNodeComponent* selected = selectedNodes.getSelectedItem (i); if (selected != inputs && selected != outputs) selected->setTopLeftPosition (selected->getX(), selected->getY() - 1); } } else if (key.isKeyCode (KeyPress::downKey)) { for (int i = 0; i < selectedNodes.getNumSelected (); i++) { GraphNodeComponent* selected = selectedNodes.getSelectedItem (i); if (selected != inputs && selected != outputs) selected->setTopLeftPosition (selected->getX(), selected->getY() + 1); } } else if (key.isKeyCode (KeyPress::deleteKey)) { closeSelectedPlugins (); } else { return Component::keyPressed (key); } return true; }
bool GenericEditor::keyPressed (const KeyPress& key) { //std::cout << name << " received " << key.getKeyCode() << std::endl; if (key.getKeyCode() == key.deleteKey || key.getKeyCode() == key.backspaceKey) { //std::cout << name << " should be deleted." << std::endl; viewport->deleteNode(this); } else if (key.getKeyCode() == key.leftKey || key.getKeyCode() == key.rightKey) { viewport->moveSelection(key); } }
bool ControlPanel::keyPressed(const KeyPress& key) { std::cout << "Control panel received" << key.getKeyCode() << std::endl; return false; }
bool SpikeDisplayCanvas::keyPressed(const KeyPress& key) { KeyPress c = KeyPress::createFromDescription("c"); if (key.isKeyCode(c.getKeyCode())) // C { spikeDisplay->clear(); std::cout << "Clearing display" << std::endl; return true; } return false; }
bool VstPluginExternalEditor::keyPressed (const KeyPress &key) { #if defined(LINUX) if (! handle) return false; XEvent ev; zerostruct (ev); ev.xkey.type = 2; // KeyPress ev.xkey.display = display; ev.xkey.window = handle; ev.xkey.root = RootWindow (display, DefaultScreen (display)); ev.xkey.subwindow = None; ev.xkey.time = CurrentTime; // ev.xkey.x = e.x; // ev.xkey.y = e.y; // ev.xkey.x_root = e.getScreenX (); // ev.xkey.y_root = e.getScreenY (); // ev.xkey.state = e.y; ev.xkey.keycode = key.getKeyCode(); ev.xkey.same_screen = True; sendEventToChild (& ev); return true; #else return false; #endif }
//============================================================================== bool CodeEditorComponent::keyPressed (const KeyPress& key) { if (! TextEditorKeyMapper<CodeEditorComponent>::invokeKeyFunction (*this, key)) { if (key == KeyPress::tabKey || key.getTextCharacter() == '\t') handleTabKey(); else if (key == KeyPress::returnKey) handleReturnKey(); else if (key == KeyPress::escapeKey) handleEscapeKey(); else if (key == KeyPress ('[', ModifierKeys::commandModifier, 0)) unindentSelection(); else if (key == KeyPress (']', ModifierKeys::commandModifier, 0)) indentSelection(); else if (key.getTextCharacter() >= ' ') insertTextAtCaret (String::charToString (key.getTextCharacter())); else return false; } pimpl->handleUpdateNowIfNeeded(); return true; }
bool FileBrowserComponent::keyPressed (const KeyPress& key) { (void) key; #if JUCE_LINUX || JUCE_WINDOWS if (key.getModifiers().isCommandDown() && (key.getKeyCode() == 'H' || key.getKeyCode() == 'h')) { fileList->setIgnoresHiddenFiles (! fileList->ignoresHiddenFiles()); fileList->refresh(); return true; } #endif return false; }
void setNewKey (const KeyPress& newKey, bool dontAskUser) { if (newKey.isValid()) { const CommandID previousCommand = owner.getMappings().findCommandForKeyPress (newKey); if (previousCommand == 0 || dontAskUser) { owner.getMappings().removeKeyPress (newKey); if (keyNum >= 0) owner.getMappings().removeKeyPress (commandID, keyNum); owner.getMappings().addKeyPress (commandID, newKey, keyNum); } else { AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, TRANS("Change key-mapping"), TRANS("This key is already assigned to the command \"") + owner.getCommandManager().getNameOfCommand (previousCommand) + TRANS("\"\n\nDo you want to re-assign it to this new command instead?"), TRANS("Re-assign"), TRANS("Cancel"), this, ModalCallbackFunction::forComponent (assignNewKeyCallback, this, KeyPress (newKey))); } } }
bool ColumnFileBrowserContents::keyPressed (const KeyPress& key) { if (key.isKeyCode (KeyPress::leftKey)) { if (activeColumn != 0) { FileListComponent* list = dynamic_cast<FileListComponent*> (columns[activeColumn]->getDisplayComponent()); list->deselectAllRows(); int newActiveColumn = jmax (0, activeColumn - 1); columns[newActiveColumn]->selectionChanged(); columns[newActiveColumn]->grabKeyboardFocus(); } return true; } else if (key.isKeyCode (KeyPress::rightKey)) { if (columns[activeColumn]->getNumSelectedFiles() == 1 && columns[activeColumn]->getSelectedFile (0).isDirectory() && getNumValidChildFiles (columns[activeColumn]->getSelectedFile (0)) > 0) { int newActiveColumn = activeColumn + 1; addColumn (columns[activeColumn]->getSelectedFile (0)); FileListComponent* list = dynamic_cast<FileListComponent*> (columns[newActiveColumn]->getDisplayComponent()); if (list != nullptr) { ListBoxModel* model = list->getModel(); if (model != nullptr) { if (model->getNumRows() > 0) { columns[newActiveColumn]->grabKeyboardFocus(); list->selectRow (0); } } } } return true; } return false; }
bool checkKeys(KeyPress key, Display display, Notification notification, vector<int> keyCodeArray, bool isMenu) { display.updateDisplay(key); system("CLS"); cout << display.toString(); while (true) { for (int i = 0; i < keyCodeArray.size(); i++) { if (key.isPressed(keyCodeArray.at(i))) { display.updateDisplay(key); system("CLS"); cout << display.toString(); }; } //extra logic for if the display is not a menu: if (!isMenu) { if (key.timedUpdate(1)) { display.updateDisplay(key); system("CLS"); cout << display.toString(); } key.isHeld(VK_SPACE); notification.lockedScreen(stoi(key.getLockedScreenPercent()), key.getSecondsLocked()); key.incrementLoopCount(); } //reset counter and key presses if (key.checkIfRequiresReset()) break; Sleep(10); } return 0; }
// Component::keyPressed ( const KeyPress & key ) bool NumberBox::keyPressed(const KeyPress & key) { // Bouml preserved body begin 0004868D if(String("0123456789.,-+").indexOfChar(key.getTextCharacter()) > -1 || key == KeyPress::returnKey || key.isKeyCode (KeyPress::escapeKey) ) { TextEditor::keyPressed(key); } return false; // Bouml preserved body end 0004868D }
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here... bool CtrlrLuaConsole::keyPressed (const KeyPress& key, Component* originatingComponent) { if (key.getKeyCode() == 13 && originatingComponent == luaConsoleInput && !key.getModifiers().isCtrlDown()) { runCode(inputDocument.getAllContent()); if ((bool)owner.getProperty(Ids::uiLuaConsoleInputRemoveAfterRun)) { inputDocument.replaceAllContent(String::empty); } return (true); } else if (key.getKeyCode() == 13 && originatingComponent == luaConsoleInput && key.getModifiers().isCtrlDown()) { luaConsoleInput->insertTextAtCaret ("\n"); } return (false); }
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here... bool CtrlrLuaConsole::keyPressed (const KeyPress& key, Component* originatingComponent) { if (key.getKeyCode() == 13 && originatingComponent == luaConsoleInput && !key.getModifiers().isCtrlDown()) { runCode(inputDocument.getAllContent()); if ((bool)owner.getProperty(Ids::uiLuaConsoleInputRemoveAfterRun)) { inputDocument.replaceAllContent(String::empty); } return (true); } else if (key.getKeyCode() == 13 && originatingComponent == luaConsoleInput && key.getModifiers().isCtrlDown()) { luaConsoleInput->insertTextAtCaret ("\n"); return (true); } else if (key.getKeyCode() == KeyPress::upKey && key.getModifiers().isCtrlDown() && originatingComponent == luaConsoleInput ) { if(inputHistory.size()) { // Prev command if (nextUpKeyPressWillbeFirst) { currentInputString = inputDocument.getAllContent(); nextUpKeyPressWillbeFirst = false; } luaConsoleInput->loadContent(inputHistory[lastCommandNumInHistory]); /* Put text at pointer into console */ lastCommandNumInHistory = ( ((lastCommandNumInHistory - 1) < 0) ? 0 : (lastCommandNumInHistory - 1) ); lastMoveDirection = UP; } return (true); } else if (key.getKeyCode() == KeyPress::downKey && key.getModifiers().isCtrlDown() && originatingComponent == luaConsoleInput) { if(inputHistory.size()) { // next command if (lastCommandNumInHistory == (inputHistory.size() - 1)) // at last command only { if (!currentInputString.isEmpty()) { luaConsoleInput->loadContent(currentInputString); nextUpKeyPressWillbeFirst = true; // if user changes this restored text we need to capture it at up key again } return true; } lastCommandNumInHistory += 1; luaConsoleInput->loadContent(inputHistory[lastCommandNumInHistory]); /* Put text at pointer into console */ lastMoveDirection = DOWN; } return (true); } return (false); }
bool ApiCollection::MethodItem::keyPressed(const KeyPress& key) { if (key.isKeyCode(KeyPress::returnKey)) { insertIntoCodeEditor(); return true; } return false; }
bool MenuBarComponent::keyPressed (const KeyPress& key) { bool used = false; const int numMenus = menuNames.size(); const int currentIndex = jlimit (0, menuNames.size() - 1, currentPopupIndex); if (key.isKeyCode (KeyPress::leftKey)) { showMenu ((currentIndex + numMenus - 1) % numMenus); used = true; } else if (key.isKeyCode (KeyPress::rightKey)) { showMenu ((currentIndex + 1) % numMenus); used = true; } return used; }
bool CallOutBox::keyPressed (const KeyPress& key) { if (key.isKeyCode (KeyPress::escapeKey)) { inputAttemptWhenModal(); return true; } return false; }
bool Button::keyPressed (const KeyPress& key) { if (isEnabled() && key.isKeyCode (KeyPress::returnKey)) { triggerClick(); return true; } return false; }
//============================================================================== void Button::addShortcut (const KeyPress& key) { if (key.isValid()) { jassert (! isRegisteredForShortcut (key)); // already registered! shortcuts.add (key); parentHierarchyChanged(); } }