当前位置: 首页>>代码示例>>C++>>正文


C++ KeyPress类代码示例

本文整理汇总了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());
}
开发者ID:atomicstack,项目名称:ctrlr,代码行数:29,代码来源:keys.cpp

示例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;
}
开发者ID:Snaptags,项目名称:MIDI2LR,代码行数:29,代码来源:CommandTable.cpp

示例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;
}
开发者ID:SonicPotions,项目名称:editor,代码行数:30,代码来源:juce_CodeEditorComponent.cpp

示例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");
}
开发者ID:Caellian,项目名称:minetest,代码行数:29,代码来源:test_keycode.cpp

示例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;
}
开发者ID:sonic59,项目名称:JuceS1Text,代码行数:29,代码来源:juce_ComboBox.cpp

示例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;
}
开发者ID:Amcut,项目名称:pizmidi,代码行数:26,代码来源:juce_AlertWindow.cpp

示例7: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    KeyPress *keyPress = new KeyPress();
    keyPress->show();

    return a.exec();
}
开发者ID:dikshabhatti,项目名称:Codes_so_far,代码行数:9,代码来源:main.cpp

示例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;
}
开发者ID:Xaetrz,项目名称:AddSyn,代码行数:10,代码来源:jucer_JucerDocumentEditor.cpp

示例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();
}
开发者ID:artisdom,项目名称:cpp_snippets,代码行数:12,代码来源:keypress_main.cpp

示例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);
}
开发者ID:orisha85,项目名称:edoapp,代码行数:51,代码来源:Win32Notification.cpp

示例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]
}
开发者ID:EQ4,项目名称:AlloGain,代码行数:14,代码来源:MainComponent.cpp

示例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;
}
开发者ID:alessandropetrolati,项目名称:juced,代码行数:49,代码来源:GraphComponent.cpp

示例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);

    }
}
开发者ID:maureddino,项目名称:arte-ephys,代码行数:15,代码来源:GenericEditor.cpp

示例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;
}
开发者ID:randi2kewl,项目名称:ShoutOut,代码行数:16,代码来源:juce_FileBrowserComponent.cpp

示例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;

}
开发者ID:Platuske,项目名称:GUI,代码行数:16,代码来源:SpikeDisplayCanvas.cpp


注:本文中的KeyPress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。