本文整理汇总了C++中KeyPress::getModifiers方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyPress::getModifiers方法的具体用法?C++ KeyPress::getModifiers怎么用?C++ KeyPress::getModifiers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyPress
的用法示例。
在下文中一共展示了KeyPress::getModifiers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressed
bool ComponentLayoutEditor::keyPressed (const KeyPress& key)
{
const bool snap = key.getModifiers().isAltDown();
const bool stretch = key.getModifiers().isShiftDown();
const int amount = snap ? document.getSnappingGridSize() + 1
: 1;
if (key.isKeyCode (KeyPress::rightKey))
{
moveOrStretch (layout, amount, 0, snap, stretch);
}
else if (key.isKeyCode (KeyPress::downKey))
{
moveOrStretch (layout, 0,amount, snap, stretch);
}
else if (key.isKeyCode (KeyPress::leftKey))
{
moveOrStretch (layout, -amount, 0, snap, stretch);
}
else if (key.isKeyCode (KeyPress::upKey))
{
moveOrStretch (layout, 0, -amount, snap, stretch);
}
else
{
return false;
}
return true;
}
示例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 BasicFileBrowser::keyPressed (const KeyPress& 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
key.getModifiers().isCommandDown();
return false;
}
示例5: 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());
}
示例6: 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);
}
示例7: 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);
}
示例8: keyPressed
bool keyPressed (const KeyPress& key) override
{
if (Viewport::respondsToKey (key))
{
const int allowableMods = owner.multipleSelection ? ModifierKeys::shiftModifier : 0;
if ((key.getModifiers().getRawFlags() & ~allowableMods) == 0)
{
// we want to avoid these keypresses going to the viewport, and instead allow
// them to pass up to our listbox..
return false;
}
}
return Viewport::keyPressed (key);
}
示例9: 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));
}
}
示例10: addKeyPress
void KeyPressMappingSet::addKeyPress (const CommandID commandID, const KeyPress& newKeyPress, int insertIndex)
{
// If you specify an upper-case letter but no shift key, how is the user supposed to press it!?
// Stick to lower-case letters when defining a keypress, to avoid ambiguity.
jassert (! (CharacterFunctions::isUpperCase (newKeyPress.getTextCharacter())
&& ! newKeyPress.getModifiers().isShiftDown()));
if (findCommandForKeyPress (newKeyPress) != commandID)
{
if (newKeyPress.isValid())
{
for (int i = mappings.size(); --i >= 0;)
{
if (mappings.getUnchecked(i)->commandID == commandID)
{
mappings.getUnchecked(i)->keypresses.insert (insertIndex, newKeyPress);
sendChangeMessage();
return;
}
}
if (const ApplicationCommandInfo* const ci = commandManager.getCommandForID (commandID))
{
CommandMapping* const cm = new CommandMapping();
cm->commandID = commandID;
cm->keypresses.add (newKeyPress);
cm->wantsKeyUpDownCallbacks = (ci->flags & ApplicationCommandInfo::wantsKeyUpDownCallbacks) != 0;
mappings.add (cm);
sendChangeMessage();
}
else
{
// If you hit this, you're trying to attach a keypress to a command ID that
// doesn't exist, so the key is not being attached.
jassertfalse;
}
}
}
}
示例11: keyPressed
bool ScumblerComponent::keyPressed(const KeyPress& key)
{
bool retval = false;
if (key.isKeyCode(KeyPress::tabKey))
{
ModifierKeys mod = key.getModifiers();
if (mod.isShiftDown())
{
fScumbler->ActivatePreviousTrack();
}
else
{
fScumbler->ActivateNextTrack();
}
retval = true;
}
else
{
retval = false;
}
return retval;
}
示例12: 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;
}
示例13: keyPressed
bool CtrlrLuaMethodCodeEditor::keyPressed (const KeyPress &key, Component *originatingComponent)
{
if (key.getModifiers().isCommandDown() )
{
if(key.getKeyCode() == 9)
{
owner.keyPressed (key, originatingComponent);
return (true);
}
if (key.getKeyCode() == 83) // CTRL + S
{
saveDocument();
return (true);
}
if (CharacterFunctions::toUpperCase ((juce_wchar) (key.getKeyCode())) == 70) // CTRL + F
{
// Show search Dialog
editorComponent->showFindPanel();
return (true);
}
if (CharacterFunctions::toUpperCase ((juce_wchar) (key.getKeyCode())) == 71) // CTRL + G
{
// Show Go To Dialog
editorComponent->showGoTOPanel();
return (true);
}
if (CharacterFunctions::toUpperCase ((juce_wchar) (key.getKeyCode())) == 72) // CTRL + H
{
// Show search Dialog
editorComponent->showFindPanel(true);
return (true);
}
if (key.getKeyCode() == KeyPress::deleteKey) // CTRL + Delete
{
owner.keyPressed(key, originatingComponent);
return (true);
}
// search selected previous in current
if (key.getModifiers().isShiftDown()
&& key.getKeyCode() == KeyPress::F3Key) // CTRL + SHIFT + F3
{
editorComponent->findSelection(false);
return (true);
}
}
// search selected next in current
if (key.getModifiers().isShiftDown() && key.getKeyCode() == KeyPress::F3Key) // SHIFT + F3
{
editorComponent->findSelection(true);
return (true);
}
if (key.getKeyCode() == KeyPress::F7Key)
{
saveAndCompileDocument();
return (true);
}
if (key.getKeyCode() == KeyPress::F8Key)
{
owner.saveAndCompilAllMethods();
return (true);
}
CodeDocument::Position pos = editorComponent->getCaretPos();
owner.setPositionLabelText ("Line: " + String(pos.getLineNumber()+1) + " Column: " + String(pos.getIndexInLine()));
return (false);
}
示例14: keyPressed
//==============================================================================
bool ListBox::keyPressed (const KeyPress& key)
{
const int numVisibleRows = viewport->getHeight() / getRowHeight();
const bool multiple = multipleSelection
&& (lastRowSelected >= 0)
&& (key.getModifiers().isShiftDown()
|| key.getModifiers().isCtrlDown()
|| key.getModifiers().isCommandDown());
if (key.isKeyCode (KeyPress::upKey))
{
if (multiple)
selectRangeOfRows (lastRowSelected, lastRowSelected - 1);
else
selectRow (jmax (0, lastRowSelected - 1));
}
else if (key.isKeyCode (KeyPress::returnKey)
&& isRowSelected (lastRowSelected))
{
if (model != nullptr)
model->returnKeyPressed (lastRowSelected);
}
else if (key.isKeyCode (KeyPress::pageUpKey))
{
if (multiple)
selectRangeOfRows (lastRowSelected, lastRowSelected - numVisibleRows);
else
selectRow (jmax (0, jmax (0, lastRowSelected) - numVisibleRows));
}
else if (key.isKeyCode (KeyPress::pageDownKey))
{
if (multiple)
selectRangeOfRows (lastRowSelected, lastRowSelected + numVisibleRows);
else
selectRow (jmin (totalItems - 1, jmax (0, lastRowSelected) + numVisibleRows));
}
else if (key.isKeyCode (KeyPress::homeKey))
{
if (multiple && key.getModifiers().isShiftDown())
selectRangeOfRows (lastRowSelected, 0);
else
selectRow (0);
}
else if (key.isKeyCode (KeyPress::endKey))
{
if (multiple && key.getModifiers().isShiftDown())
selectRangeOfRows (lastRowSelected, totalItems - 1);
else
selectRow (totalItems - 1);
}
else if (key.isKeyCode (KeyPress::downKey))
{
if (multiple)
selectRangeOfRows (lastRowSelected, lastRowSelected + 1);
else
selectRow (jmin (totalItems - 1, jmax (0, lastRowSelected) + 1));
}
else if ((key.isKeyCode (KeyPress::deleteKey) || key.isKeyCode (KeyPress::backspaceKey))
&& isRowSelected (lastRowSelected))
{
if (model != nullptr)
model->deleteKeyPressed (lastRowSelected);
}
else if (multiple && key == KeyPress ('a', ModifierKeys::commandModifier, 0))
{
selectRangeOfRows (0, std::numeric_limits<int>::max());
}
else
{
return false;
}
return true;
}
示例15: keyPressed
//==============================================================================
bool CodeEditorComponent::keyPressed (const KeyPress& key)
{
const bool moveInWholeWordSteps = key.getModifiers().isCtrlDown() || key.getModifiers().isAltDown();
const bool shiftDown = key.getModifiers().isShiftDown();
if (key.isKeyCode (KeyPress::leftKey))
{
cursorLeft (moveInWholeWordSteps, shiftDown);
}
else if (key.isKeyCode (KeyPress::rightKey))
{
cursorRight (moveInWholeWordSteps, shiftDown);
}
else if (key.isKeyCode (KeyPress::upKey))
{
if (key.getModifiers().isCtrlDown() && ! shiftDown)
scrollDown();
#if JUCE_MAC
else if (key.getModifiers().isCommandDown())
goToStartOfDocument (shiftDown);
#endif
else
cursorUp (shiftDown);
}
else if (key.isKeyCode (KeyPress::downKey))
{
if (key.getModifiers().isCtrlDown() && ! shiftDown)
scrollUp();
#if JUCE_MAC
else if (key.getModifiers().isCommandDown())
goToEndOfDocument (shiftDown);
#endif
else
cursorDown (shiftDown);
}
else if (key.isKeyCode (KeyPress::pageDownKey))
{
pageDown (shiftDown);
}
else if (key.isKeyCode (KeyPress::pageUpKey))
{
pageUp (shiftDown);
}
else if (key.isKeyCode (KeyPress::homeKey))
{
if (moveInWholeWordSteps)
goToStartOfDocument (shiftDown);
else
goToStartOfLine (shiftDown);
}
else if (key.isKeyCode (KeyPress::endKey))
{
if (moveInWholeWordSteps)
goToEndOfDocument (shiftDown);
else
goToEndOfLine (shiftDown);
}
else if (key.isKeyCode (KeyPress::backspaceKey))
{
backspace (moveInWholeWordSteps);
}
else if (key.isKeyCode (KeyPress::deleteKey))
{
deleteForward (moveInWholeWordSteps);
}
else if (key == KeyPress (T('c'), ModifierKeys::commandModifier, 0))
{
copy();
}
else if (key == KeyPress (T('x'), ModifierKeys::commandModifier, 0))
{
copyThenCut();
}
else if (key == KeyPress (T('v'), ModifierKeys::commandModifier, 0))
{
paste();
}
else if (key == KeyPress (T('z'), ModifierKeys::commandModifier, 0))
{
undo();
}
else if (key == KeyPress (T('y'), ModifierKeys::commandModifier, 0)
|| key == KeyPress (T('z'), ModifierKeys::commandModifier | ModifierKeys::shiftModifier, 0))
{
redo();
}
else if (key == KeyPress (T('a'), ModifierKeys::commandModifier, 0))
{
selectAll();
}
else if (key == KeyPress::tabKey || key.getTextCharacter() == '\t')
{
insertTabAtCaret();
}
else if (key == KeyPress::returnKey)
{
newTransaction();
insertTextAtCaret (document.getNewLineCharacters());
}
//.........这里部分代码省略.........