本文整理汇总了C++中WeakReference::grabKeyboardFocus方法的典型用法代码示例。如果您正苦于以下问题:C++ WeakReference::grabKeyboardFocus方法的具体用法?C++ WeakReference::grabKeyboardFocus怎么用?C++ WeakReference::grabKeyboardFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeakReference
的用法示例。
在下文中一共展示了WeakReference::grabKeyboardFocus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runEventLoopForCurrentComponent
int ModalComponentManager::runEventLoopForCurrentComponent()
{
// This can only be run from the message thread!
jassert (MessageManager::getInstance()->isThisTheMessageThread());
Component* currentlyModal = getModalComponent (0);
if (currentlyModal == nullptr)
return 0;
WeakReference<Component> prevFocused (Component::getCurrentlyFocusedComponent());
int returnValue = 0;
bool finished = false;
attachCallback (currentlyModal, new ReturnValueRetriever (returnValue, finished));
JUCE_TRY
{
while (! finished)
{
if (! MessageManager::getInstance()->runDispatchLoopUntil (20))
break;
}
}
JUCE_CATCH_EXCEPTION
if (prevFocused != nullptr)
prevFocused->grabKeyboardFocus();
return returnValue;
}
示例2: showDialog
bool FileChooser::showDialog (const bool selectsDirectories,
const bool selectsFiles,
const bool isSave,
const bool warnAboutOverwritingExistingFiles,
const bool selectMultipleFiles,
FilePreviewComponent* const previewComponent)
{
WeakReference<Component> previouslyFocused (Component::getCurrentlyFocusedComponent());
results.clear();
// the preview component needs to be the right size before you pass it in here..
jassert (previewComponent == nullptr || (previewComponent->getWidth() > 10
&& previewComponent->getHeight() > 10));
#if JUCE_WINDOWS
if (useNativeDialogBox && ! (selectsFiles && selectsDirectories))
#elif JUCE_MAC || JUCE_LINUX
if (useNativeDialogBox && (previewComponent == nullptr))
#else
if (false)
#endif
{
showPlatformDialog (results, title, startingFile, filters,
selectsDirectories, selectsFiles, isSave,
warnAboutOverwritingExistingFiles,
selectMultipleFiles,
previewComponent);
}
else
{
WildcardFileFilter wildcard (selectsFiles ? filters : String::empty,
selectsDirectories ? "*" : String::empty,
String::empty);
int flags = isSave ? FileBrowserComponent::saveMode
: FileBrowserComponent::openMode;
if (selectsFiles)
flags |= FileBrowserComponent::canSelectFiles;
if (selectsDirectories)
{
flags |= FileBrowserComponent::canSelectDirectories;
if (! isSave)
flags |= FileBrowserComponent::filenameBoxIsReadOnly;
}
if (selectMultipleFiles)
flags |= FileBrowserComponent::canSelectMultipleItems;
FileBrowserComponent browserComponent (flags, startingFile, &wildcard, previewComponent);
FileChooserDialogBox box (title, String::empty,
browserComponent,
warnAboutOverwritingExistingFiles,
browserComponent.findColour (AlertWindow::backgroundColourId));
if (box.show())
{
for (int i = 0; i < browserComponent.getNumSelectedFiles(); ++i)
results.add (browserComponent.getSelectedFile (i));
}
}
if (previouslyFocused != nullptr)
previouslyFocused->grabKeyboardFocus();
return results.size() > 0;
}