本文整理汇总了C++中KeyPress::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyPress::isValid方法的具体用法?C++ KeyPress::isValid怎么用?C++ KeyPress::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyPress
的用法示例。
在下文中一共展示了KeyPress::isValid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setNewKey
void setNewKey (const KeyPress& newKey, bool dontAskUser)
{
if (newKey.isValid())
{
const CommandID previousCommand = owner.getMappings().findCommandForKeyPress (newKey);
if (previousCommand == 0 || dontAskUser)
{
owner.getMappings().removeKeyPress (newKey);
if (keyNum >= 0)
owner.getMappings().removeKeyPress (commandID, keyNum);
owner.getMappings().addKeyPress (commandID, newKey, keyNum);
}
else
{
AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
TRANS("Change key-mapping"),
TRANS("This key is already assigned to the command \"")
+ owner.getCommandManager().getNameOfCommand (previousCommand)
+ TRANS("\"\n\nDo you want to re-assign it to this new command instead?"),
TRANS("Re-assign"),
TRANS("Cancel"),
this,
ModalCallbackFunction::forComponent (assignNewKeyCallback,
this, KeyPress (newKey)));
}
}
}
示例2: addShortcut
//==============================================================================
void Button::addShortcut (const KeyPress& key)
{
if (key.isValid())
{
jassert (! isRegisteredForShortcut (key)); // already registered!
shortcuts.add (key);
parentHierarchyChanged();
}
}
示例3: removeKeyPress
void KeyPressMappingSet::removeKeyPress (const KeyPress& keypress)
{
if (keypress.isValid())
{
for (int i = mappings.size(); --i >= 0;)
{
CommandMapping* const cm = mappings.getUnchecked(i);
for (int j = cm->keypresses.size(); --j >= 0;)
{
if (keypress == cm->keypresses [j])
{
cm->keypresses.remove (j);
sendChangeMessage();
}
}
}
}
}
示例4: 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;
}
}
}
}