本文整理汇总了C++中KeyPress::isKeyCode方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyPress::isKeyCode方法的具体用法?C++ KeyPress::isKeyCode怎么用?C++ KeyPress::isKeyCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyPress
的用法示例。
在下文中一共展示了KeyPress::isKeyCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressed
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;
}
示例2: 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;
}
示例3: keyPressed
//==============================================================================
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;
}
示例4: keyPressed
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;
}
示例5: 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;
}
示例6: 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;
}
示例7: keyPressed
//==============================================================================
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;
}
示例8: keyPressed
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;
}
示例9: keyPressed
bool Button::keyPressed (const KeyPress& key)
{
if (isEnabled() && key.isKeyCode (KeyPress::returnKey))
{
triggerClick();
return true;
}
return false;
}
示例10: keyPressed
bool CallOutBox::keyPressed (const KeyPress& key)
{
if (key.isKeyCode (KeyPress::escapeKey))
{
inputAttemptWhenModal();
return true;
}
return false;
}
示例11: keyPressed
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;
}
示例12:
bool ApiCollection::MethodItem::keyPressed(const KeyPress& key)
{
if (key.isKeyCode(KeyPress::returnKey))
{
insertIntoCodeEditor();
return true;
}
return false;
}
示例13: keyPressed
bool SlicerChannelSelectorComponent::keyPressed (const KeyPress& key, Component* originatingComponent)
{
// Collapse component by clicking "ESC" key either on component or in the TextEditor
if ( (dynamic_cast<TextEditor*> (originatingComponent) != nullptr
|| originatingComponent == this)
&& key.isKeyCode (KeyPress::escapeKey))
{
setCollapsed (true);
}
return false;
}
示例14: keyPressed
bool ScrollBar::keyPressed (const KeyPress& key)
{
if (! isVisible())
return false;
if (key.isKeyCode (KeyPress::upKey)
|| key.isKeyCode (KeyPress::leftKey)) moveScrollbarInSteps (-1);
else if (key.isKeyCode (KeyPress::downKey)
|| key.isKeyCode (KeyPress::rightKey)) moveScrollbarInSteps (1);
else if (key.isKeyCode (KeyPress::pageUpKey)) moveScrollbarInPages (-1);
else if (key.isKeyCode (KeyPress::pageDownKey)) moveScrollbarInPages (1);
else if (key.isKeyCode (KeyPress::homeKey)) scrollToTop();
else if (key.isKeyCode (KeyPress::endKey)) scrollToBottom();
else return false;
return true;
}
示例15: keyPressed
//==============================================================================
bool ComboBox::keyPressed (const KeyPress& key)
{
bool used = false;
if (key.isKeyCode (KeyPress::upKey)
|| key.isKeyCode (KeyPress::leftKey))
{
setSelectedItemIndex (jmax (0, getSelectedItemIndex() - 1));
used = true;
}
else if (key.isKeyCode (KeyPress::downKey)
|| key.isKeyCode (KeyPress::rightKey))
{
setSelectedItemIndex (jmin (getSelectedItemIndex() + 1, getNumItems() - 1));
used = true;
}
else if (key.isKeyCode (KeyPress::returnKey))
{
showPopup();
used = true;
}
return used;
}