本文整理汇总了C++中KeyPress::getKeyCode方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyPress::getKeyCode方法的具体用法?C++ KeyPress::getKeyCode怎么用?C++ KeyPress::getKeyCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyPress
的用法示例。
在下文中一共展示了KeyPress::getKeyCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ctrlr_sendKeyPressEvent
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());
}
示例2: keyPressed
//[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);
}
示例3: keyPressed
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]
}
示例4: keyPressed
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);
}
}
示例5: keyPressed
bool ControlPanel::keyPressed(const KeyPress& key)
{
std::cout << "Control panel received" << key.getKeyCode() << std::endl;
return false;
}
示例6: keyPressed
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
}
示例7: keyPressed
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;
}
示例8: keyPressed
//[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);
}
示例9: keyPressed
bool TextBuffer::keyPressed (const KeyPress& key)
{
//std::cout << "keyPressed: " << key.getTextDescription().toUTF8() << T("\n");
if (isMatching())
stopMatching();
TextEditor::keyPressed(key);
juce_wchar chr=key.getTextCharacter();
CommandID com=CommandIDs::EditorTextChanged;
if (key.getKeyCode()==KeyPress::returnKey)
com=CommandIDs::EditorNewline;
else if (key.getKeyCode()==KeyPress::backspaceKey)
com=CommandIDs::EditorBackspace;
else if (!testFlag(EditFlags::MatchingOff) &&
(chr==')' || ((textid==TextIDs::Sal) && chr=='}') || ((textid==TextIDs::Sal2) && chr=='}')))
matchParens();
colorizeAfterChange(com);
setFlag(EditFlags::NeedsSave);
return true;
}
示例10: keyPressed
bool CtrlrLuaMethodEditor::keyPressed (const KeyPress& key, Component* originatingComponent)
{
if (key.getModifiers().isCommandDown())
{
if (key.getKeyCode() == 70)
{
// CTRL + F
methodEditArea->showFindDialog();
}
if (key.getKeyCode() == 72)
{
methodEditArea->replaceNextMatch();
}
}
if (key.getKeyCode() == 65650) // F3
{
methodEditArea->findNextMatch();
}
return false;
}
示例11: sizeof
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);
}
示例12: keyPressed
bool keyPressed( const KeyPress& keyPress )
{
int iKeyCode = toupper(keyPress.getKeyCode());
if ( iKeyCode == KeyPress::escapeKey )
{
JUCEApplication::quit();
return true;
}
if ( iKeyCode == KeyPress::upKey )
{
m_camera.RotateOrbit( 0, 0, LeapUtil::kfHalfPi * -0.05f );
return true;
}
if ( iKeyCode == KeyPress::downKey )
{
m_camera.RotateOrbit( 0, 0, LeapUtil::kfHalfPi * 0.05f );
return true;
}
if ( iKeyCode == KeyPress::leftKey )
{
m_camera.RotateOrbit( 0, LeapUtil::kfHalfPi * -0.05f, 0 );
return true;
}
if ( iKeyCode == KeyPress::rightKey )
{
m_camera.RotateOrbit( 0, LeapUtil::kfHalfPi * 0.05f, 0 );
return true;
}
switch( iKeyCode )
{
case ' ':
resetCamera();
break;
case 'H':
m_bShowHelp = !m_bShowHelp;
break;
case 'P':
m_bPaused = !m_bPaused;
break;
default:
return false;
}
return true;
}
示例13: sendKey
static void sendKey(const KeyPress &event)
{
INPUT input;
input.type = INPUT_KEYBOARD;
input.ki.time = 0;
input.ki.dwExtraInfo = 0;
input.ki.wScan = 0;
input.ki.dwFlags = 0;
// Modifier Down
if (event.getModifiers().isCommandDown())
{
input.ki.wVk = VK_CONTROL;
SendInput(1, &input, sizeof(INPUT));
}
if (event.getModifiers().isAltDown())
{
input.ki.wVk = VK_MENU;
SendInput(1, &input, sizeof(INPUT));
}
if (event.getModifiers().isShiftDown())
{
input.ki.wVk = VK_SHIFT;
SendInput(1, &input, sizeof(INPUT));
}
// KEY Down
input.ki.wVk = event.getKeyCode();
SendInput(1, &input, sizeof(INPUT));
// KEY Up
input.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &input, sizeof(INPUT));
// MODIFIER Up
if (event.getModifiers().isCommandDown())
{
input.ki.wVk = VK_CONTROL;
SendInput(1, &input, sizeof(INPUT));
}
if (event.getModifiers().isAltDown())
{
input.ki.wVk = VK_MENU;
SendInput(1, &input, sizeof(INPUT));
}
if (event.getModifiers().isShiftDown())
{
input.ki.wVk = VK_SHIFT;
SendInput(1, &input, sizeof(INPUT));
}
}
示例14: keyPressed
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;
}
示例15: keyPressed
bool ScannerManagerComponent::keyPressed (const KeyPress &k, Component* originatingComponent)
{
if (k.getKeyCode() == k.backspaceKey)
{
for (unsigned i = 0; i < cues.size(); i++)
{
if (cues[i]->isSelected())
{
removeCue (i);
repaint ();
return true;
}
}
return false;
}
return false;
}