本文整理汇总了C++中Shortcut::is_pressed方法的典型用法代码示例。如果您正苦于以下问题:C++ Shortcut::is_pressed方法的具体用法?C++ Shortcut::is_pressed怎么用?C++ Shortcut::is_pressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shortcut
的用法示例。
在下文中一共展示了Shortcut::is_pressed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onProcessMessage
// Manager event handler.
bool CustomizedGuiManager::onProcessMessage(Message* msg)
{
switch (msg->type()) {
case kCloseAppMessage:
{
// Execute the "Exit" command.
Command* command = CommandsModule::instance()->getCommandByName(CommandId::Exit);
UIContext::instance()->executeCommand(command);
}
break;
case kDropFilesMessage:
{
// If the main window is not the current foreground one. We
// discard the drop-files event.
if (getForegroundWindow() != App::instance()->getMainWindow())
break;
const DropFilesMessage::Files& files = static_cast<DropFilesMessage*>(msg)->files();
// Open all files
Command* cmd_open_file =
CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
Params params;
for (DropFilesMessage::Files::const_iterator
it = files.begin(); it != files.end(); ++it) {
params.set("filename", it->c_str());
UIContext::instance()->executeCommand(cmd_open_file, ¶ms);
}
}
break;
case kQueueProcessingMessage:
gui_feedback();
break;
case kKeyDownMessage: {
Window* toplevel_window = getTopWindow();
// If there is a foreground window as top level...
if (toplevel_window &&
toplevel_window != App::instance()->getMainWindow() &&
toplevel_window->isForeground()) {
// We just do not process keyboard shortcuts for menus and tools
break;
}
for (Shortcut* shortcut : *shortcuts) {
if (shortcut->is_pressed(msg)) {
// Cancel menu-bar loops (to close any popup menu)
App::instance()->getMainWindow()->getMenuBar()->cancelMenuLoop();
switch (shortcut->type) {
case Shortcut::Type::ChangeTool: {
tools::Tool* current_tool = UIContext::instance()->settings()->getCurrentTool();
tools::Tool* select_this_tool = shortcut->tool;
tools::ToolBox* toolbox = App::instance()->getToolBox();
std::vector<tools::Tool*> possibles;
// Iterate over all tools
for (tools::ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
Shortcut* shortcut = get_keyboard_shortcut_for_tool(*it);
// Collect all tools with the pressed keyboard-shortcut
if (shortcut && shortcut->is_pressed(msg))
possibles.push_back(*it);
}
if (possibles.size() >= 2) {
bool done = false;
for (size_t i=0; i<possibles.size(); ++i) {
if (possibles[i] != current_tool &&
ToolBar::instance()->isToolVisible(possibles[i])) {
select_this_tool = possibles[i];
done = true;
break;
}
}
if (!done) {
for (size_t i=0; i<possibles.size(); ++i) {
// If one of the possibilities is the current tool
if (possibles[i] == current_tool) {
// We select the next tool in the possibilities
select_this_tool = possibles[(i+1) % possibles.size()];
break;
}
}
}
}
ToolBar::instance()->selectTool(select_this_tool);
return true;
}
//.........这里部分代码省略.........