本文整理汇总了C++中KeyPress函数的典型用法代码示例。如果您正苦于以下问题:C++ KeyPress函数的具体用法?C++ KeyPress怎么用?C++ KeyPress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KeyPress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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");
}
示例2: Scanner
Scanner (PluginListComponent& plc,
AudioPluginFormat& format,
PropertiesFile* properties,
int threads)
: owner (plc), formatToScan (format), propertiesToUse (properties),
pathChooserWindow (TRANS("Select folders to scan..."), String::empty, AlertWindow::NoIcon),
progressWindow (TRANS("Scanning for plug-ins..."),
TRANS("Searching for all possible plug-in files..."), AlertWindow::NoIcon),
progress (0.0), numThreads (threads), finished (false)
{
FileSearchPath path (formatToScan.getDefaultLocationsToSearch());
if (path.getNumPaths() > 0) // if the path is empty, then paths aren't used for this format.
{
if (propertiesToUse != nullptr)
path = getLastSearchPath (*propertiesToUse, formatToScan);
pathList.setSize (500, 300);
pathList.setPath (path);
pathChooserWindow.addCustomComponent (&pathList);
pathChooserWindow.addButton (TRANS("Scan"), 1, KeyPress (KeyPress::returnKey));
pathChooserWindow.addButton (TRANS("Cancel"), 0, KeyPress (KeyPress::escapeKey));
pathChooserWindow.enterModalState (true,
ModalCallbackFunction::forComponent (startScanCallback, &pathChooserWindow, this),
false);
}
else
{
startScan();
}
}
示例3: switch
void MainWindow::getCommandInfo (const CommandID commandID, ApplicationCommandInfo& result)
{
switch (commandID)
{
case CommandIDs::closeWindow:
result.setInfo ("Close Window", "Closes the current window", CommandCategories::general, 0);
result.defaultKeypresses.add (KeyPress ('w', ModifierKeys::commandModifier, 0));
break;
case CommandIDs::goToPreviousWindow:
result.setInfo ("Previous Window", "Activates the previous window", CommandCategories::general, 0);
result.setActive (ProjucerApplication::getApp().mainWindowList.windows.size() > 1);
result.defaultKeypresses.add (KeyPress (KeyPress::tabKey, ModifierKeys::shiftModifier | ModifierKeys::ctrlModifier, 0));
break;
case CommandIDs::goToNextWindow:
result.setInfo ("Next Window", "Activates the next window", CommandCategories::general, 0);
result.setActive (ProjucerApplication::getApp().mainWindowList.windows.size() > 1);
result.defaultKeypresses.add (KeyPress (KeyPress::tabKey, ModifierKeys::ctrlModifier, 0));
break;
default:
break;
}
}
示例4: category
void MainContentComponent::getCommandInfo (CommandID commandID, ApplicationCommandInfo& result)
{
const String category ("General");
switch (commandID)
{
case Ananke::menuFileOption:
result.setInfo ("File", "Create a new synth graph", category, 0);
result.defaultKeypresses.add (KeyPress ('n', ModifierKeys::commandModifier, 0));
break;
case Ananke::menuExitOption:
result.setInfo ("Exit", "Exit out of application", category, 0);
result.defaultKeypresses.add (KeyPress ('w', ModifierKeys::commandModifier, 0));
break;
case Ananke::menuSettingsOption:
result.setInfo ("Settings", "Open settings window", category, 0);
result.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier, 0));
break;
case Ananke::menuHelpOption:
result.setInfo ("Help", "Open help file", category, 0);
result.defaultKeypresses.add (KeyPress ('h', ModifierKeys::commandModifier, 0));
break;
}
}
示例5: String
PopupMenu MainContentComponent::getMenuForIndex( int menuIndex, const juce::String & )
{
PopupMenu menu;
if ( menuIndex == 0 )
{
menu.addItem( 1, "New Chaser" );
menu.addSeparator();
menu.addItem( 2, "Load Chaser" );
menu.addItem( 3, "Save Chaser as..." );
menu.addSeparator();
menu.addItem( 4, "Export Pixelmap" );
menu.addSeparator();
menu.addItem( 5, "v" + String( ProjectInfo::versionString ), false, false );
// //if there is no active assfile, stop the timer
// bool isAvailable = FileHelper::isFileValid( sliceManager->getAssFile(), false );
// if ( !isAvailable )
// autoUpdate->stop();
}
else if ( menuIndex == 1 )
{
menu.addItem( 1, "Copy Step " + KeyPress( 'c', ModifierKeys::commandModifier, NULL ).getTextDescriptionWithIcons() );
menu.addItem( 2, "Paste Step " + KeyPress( 'v', ModifierKeys::commandModifier, NULL ).getTextDescriptionWithIcons(), !stepToCopy.isEmpty() );
menu.addItem( 3, "Clear Step" );
menu.addItem( 4, "Invert Step" );
}
return menu;
}
示例6: if
bool MainContentComponent::keyPressed( const juce::KeyPress &key, juce::Component * )
{
if ( key == KeyPress::leftKey )
{
sequencer->previousStep();
}
else if ( key == KeyPress::rightKey )
{
sequencer->nextStep();
}
else if ( key == KeyPress( 'c', ModifierKeys::commandModifier, NULL ) )
{
copyStep();
}
else if ( key == KeyPress( 'v', ModifierKeys::commandModifier, NULL ) )
{
pasteStep();
}
//secret shortcut to force opening a particular assfile
else if ( key == KeyPress( 'o', ModifierKeys::commandModifier + ModifierKeys::shiftModifier, NULL ) )
{
loadAssFile();
}
return true;
}
示例7: wnd
void CtrlrLuaMethodEditor::addNewMethod(ValueTree parentGroup)
{
AlertWindow wnd(METHOD_NEW, String::empty, AlertWindow::InfoIcon, this);
wnd.addTextEditor ("methodName", "myNewMethod", "Method name", false);
wnd.addComboBox ("templateList", getMethodManager().getTemplateList(), "Initialize from template");
wnd.addButton ("OK", 1, KeyPress(KeyPress::returnKey));
wnd.addButton ("Cancel", 0, KeyPress(KeyPress::escapeKey));
if (wnd.runModalLoop())
{
const String methodName = wnd.getTextEditorContents("methodName");
if (getMethodManager().isValidMethodName(methodName))
{
const String initialCode = getMethodManager().getDefaultMethodCode(methodName, wnd.getComboBoxComponent("templateList")->getText());
getMethodManager().addMethod (parentGroup, wnd.getTextEditorContents("methodName"), initialCode, String::empty);
}
else
{
WARN("Invalid method name, please correct");
}
}
updateRootItem();
saveSettings(); // save settings
}
示例8: createNewFile
void createNewFile (Project::Item parent)
{
for (;;)
{
AlertWindow aw (TRANS ("Create new Component class"),
TRANS ("Please enter the name for the new class"),
AlertWindow::NoIcon, nullptr);
aw.addTextEditor (getClassNameFieldName(), String::empty, String::empty, false);
aw.addButton (TRANS ("Create Files"), 1, KeyPress (KeyPress::returnKey));
aw.addButton (TRANS ("Cancel"), 0, KeyPress (KeyPress::escapeKey));
if (aw.runModalLoop() == 0)
break;
const String className (aw.getTextEditorContents (getClassNameFieldName()).trim());
if (className == CodeHelpers::makeValidIdentifier (className, false, true, false))
{
const File newFile (askUserToChooseNewFile (className + ".h", "*.h;*.cpp", parent));
if (newFile != File::nonexistent)
createFiles (parent, className, newFile);
break;
}
}
}
示例9: Main
//-------------------------------------------------------------
//- Main
//- Main game loop
//-------------------------------------------------------------
void Main()
{
static float fRot = 0.0f;
static float fAnimSpeed = 1.0f;
//Input
//Pressing 'b' toggles the display of bones on and off
if(KeyPressOnce('B'))
g_ms3d.SwapBoneDraw();
//Pressing 'w' toggles the display of the meshes
if(KeyPressOnce('M'))
g_ms3d.SwapMeshDraw(); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
//Pressing left and right arrows rotate the model on the y axis
if(KeyPress(VK_RIGHT))
fRot += 0.3f;
if(KeyPress(VK_LEFT))
fRot -= 0.3f;
//Pressing the up and down arrows change the animation speed of the model
if(KeyPressOnce(VK_UP))
if(fAnimSpeed < 4.9f)
fAnimSpeed += 0.1f;
if(KeyPressOnce(VK_DOWN))
if(fAnimSpeed > 0.1f)
fAnimSpeed -= 0.1f;
//Take Screenshot
if(KeyPressOnce('P'))
CImage::ScreenShot();
//Draw controls and information on the screen
glColor3f(1.0f, 1.0f, 1.0f);
glDisable(GL_LIGHTING);
//Controls
APP->Print(0.75f, 0.9f, "FPS: %4.2f", APP->GetFPS());
APP->Print(-0.95f, 0.6f, "Controls");
APP->Print(-0.95f, 0.5f, "B - Toggle the display of bones");
APP->Print(-0.95f, 0.4f, "M - Toggle the display of the mesh");
APP->Print(-0.95f, 0.3f, "Right/Left Arrows - Rotate model on Y axis");
APP->Print(-0.95f, 0.2f, "Up/Down Arrows - Change animation speed");
APP->Print(-0.95f, 0.1f, "P - Take Screenshot");
//Info
APP->Print(0.5f, 0.6f, "Animation Speed: %1.1f", fAnimSpeed);
APP->Print(0.5f, 0.5f, "Bones: %s", (g_ms3d.AreBonesEnabled() ? "Enabled" : "Disabled"));
APP->Print(0.5f, 0.4f, "Mesh: %s", (g_ms3d.AreMeshesEnabled() ? "Enabled" : "Disabled"));
//On to the real GL stuff
glLoadIdentity();
glTranslatef(6.0f, -30.0f, -85.0f);
glRotatef(fRot, 0.0f, 1.0f, 0.0f);
glEnable(GL_LIGHTING);
g_ms3d.Animate(fAnimSpeed, 0, 2, true);
}
示例10: switch
void ProjucerApplication::getCommandInfo (CommandID commandID, ApplicationCommandInfo& result)
{
switch (commandID)
{
case CommandIDs::newProject:
result.setInfo ("New Project...", "Creates a new Jucer project", CommandCategories::general, 0);
result.defaultKeypresses.add (KeyPress ('n', ModifierKeys::commandModifier, 0));
break;
case CommandIDs::open:
result.setInfo ("Open...", "Opens a Jucer project", CommandCategories::general, 0);
result.defaultKeypresses.add (KeyPress ('o', ModifierKeys::commandModifier, 0));
break;
case CommandIDs::showGlobalPreferences:
result.setInfo ("Preferences...", "Shows the preferences window.", CommandCategories::general, 0);
result.defaultKeypresses.add (KeyPress (',', ModifierKeys::commandModifier, 0));
break;
case CommandIDs::closeAllDocuments:
result.setInfo ("Close All Documents", "Closes all open documents", CommandCategories::general, 0);
result.setActive (openDocumentManager.getNumOpenDocuments() > 0);
break;
case CommandIDs::saveAll:
result.setInfo ("Save All", "Saves all open documents", CommandCategories::general, 0);
result.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier | ModifierKeys::altModifier, 0));
break;
case CommandIDs::showUTF8Tool:
result.setInfo ("UTF-8 String-Literal Helper", "Shows the UTF-8 string literal utility", CommandCategories::general, 0);
break;
case CommandIDs::showSVGPathTool:
result.setInfo ("SVG Path Helper", "Shows the SVG->Path data conversion utility", CommandCategories::general, 0);
break;
case CommandIDs::loginLogout:
result.setInfo (ProjucerLicenses::getInstance()->isLoggedIn()
? String ("Sign out ") + ProjucerLicenses::getInstance()->getLoginName()
: String ("Sign in..."),
"Log out of your JUCE account", CommandCategories::general, 0);
result.setActive (ProjucerLicenses::getInstance()->isDLLPresent());
break;
default:
JUCEApplication::getCommandInfo (commandID, result);
break;
}
}
示例11: w
void CtrlrLuaMethodEditor::renameGroup(ValueTree parentGroup)
{
AlertWindow w ("Rename group", "", AlertWindow::QuestionIcon, this);
w.addTextEditor("name", parentGroup.getProperty (Ids::name).toString());
w.addButton ("OK", 1, KeyPress(KeyPress::returnKey));
w.addButton ("Cancel", 0, KeyPress(KeyPress::escapeKey));
if (w.runModalLoop())
{
parentGroup.setProperty (Ids::name, w.getTextEditorContents("name"), nullptr);
updateRootItem();
}
saveSettings(); // save settings
}
示例12: KeyPress
void CApplication::KeyEvent(int c, int e)
{
if (e == GLFW_PRESS)
KeyPress(MapKey(c));
else
KeyRelease(MapKey(c));
}
示例13: Plug_MenuEvent
int Plug_MenuEvent(int *args)
{
int i;
drawscalex = vid.width/640.0f;
drawscaley = vid.height/480.0f;
args[2]=(int)(args[2]/drawscalex);
args[3]=(int)(args[3]/drawscaley);
switch(args[0])
{
case 0: //draw
Draw_Colour4f(1,1,1,1);
Draw_Image(((640 - (480-16))/2)*drawscalex, 16*drawscaley, (480-16)*drawscalex, (480-16)*drawscaley, 0, 0, 1, 1, con_chars);
for (i = 0; namebuffer[i]; i++)
DrawChar(namebuffer[i], i*16, 0);
DrawChar(10 + (((currenttime/250)&1)==1), insertpos*16, 0);
break;
case 1: //keydown
KeyPress(args[1], args[2], args[3]);
break;
case 2: //keyup
break;
case 3: //menu closed (this is called even if we change it).
break;
case 4: //mousemove
break;
}
return 0;
}
示例14: state
//==============================================================================
MidiKeyboardComponent::MidiKeyboardComponent (MidiKeyboardState& s, Orientation o)
: state (s), orientation (o)
{
scrollDown.reset (new UpDownButton (*this, -1));
scrollUp .reset (new UpDownButton (*this, 1));
addChildComponent (scrollDown.get());
addChildComponent (scrollUp.get());
// initialise with a default set of qwerty key-mappings..
int note = 0;
for (char c : "awsedftgyhujkolp;")
setKeyPressForNote (KeyPress (c, 0, 0), note++);
mouseOverNotes.insertMultiple (0, -1, 32);
mouseDownNotes.insertMultiple (0, -1, 32);
colourChanged();
setWantsKeyboardFocus (true);
state.addListener (this);
startTimerHz (20);
}
示例15: state
//==============================================================================
MidiKeyboardComponent::MidiKeyboardComponent (MidiKeyboardState& state_,
const Orientation orientation_)
: state (state_),
xOffset (0),
blackNoteLength (1),
keyWidth (16.0f),
orientation (orientation_),
midiChannel (1),
midiInChannelMask (0xffff),
velocity (1.0f),
noteUnderMouse (-1),
mouseDownNote (-1),
rangeStart (0),
rangeEnd (127),
firstKey (12 * 4),
canScroll (true),
mouseDragging (false),
useMousePositionForVelocity (true),
keyMappingOctave (6),
octaveNumForMiddleC (3)
{
addChildComponent (scrollDown = new MidiKeyboardUpDownButton (*this, -1));
addChildComponent (scrollUp = new MidiKeyboardUpDownButton (*this, 1));
// initialise with a default set of querty key-mappings..
const char* const keymap = "awsedftgyhujkolp;";
for (int i = String (keymap).length(); --i >= 0;)
setKeyPressForNote (KeyPress (keymap[i], 0, 0), i);
setOpaque (true);
setWantsKeyboardFocus (true);
state.addListener (this);
}