本文整理汇总了C++中KeyPress类的典型用法代码示例。如果您正苦于以下问题:C++ KeyPress类的具体用法?C++ KeyPress怎么用?C++ KeyPress使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyPress类的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: getSelectedRow
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;
}
示例3: insertTabAtCaret
//==============================================================================
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;
}
示例4: KeyPress
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");
}
示例5: getSelectedItemIndex
//==============================================================================
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;
}
示例6: exitModalState
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;
}
示例7: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
KeyPress *keyPress = new KeyPress();
keyPress->show();
return a.exec();
}
示例8: keyPressed
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;
}
示例9: main
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();
}
示例10: 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);
}
示例11: 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]
}
示例12: if
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;
}
示例13: 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);
}
}
示例14: 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;
}
示例15: 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;
}