mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-27 02:20:05 +00:00
Used Button::onClick to simplify a bunch of library classes and demo code
This commit is contained in:
parent
be5f2d62c4
commit
ce8b2d865a
52 changed files with 557 additions and 954 deletions
|
|
@ -336,7 +336,6 @@ private:
|
|||
|
||||
//==============================================================================
|
||||
class KeyMappingEditorComponent::TopLevelItem : public TreeViewItem,
|
||||
public Button::Listener,
|
||||
private ChangeListener
|
||||
{
|
||||
public:
|
||||
|
|
@ -372,27 +371,15 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
static void resetToDefaultsCallback (int result, KeyMappingEditorComponent* owner)
|
||||
{
|
||||
if (result != 0 && owner != nullptr)
|
||||
owner->getMappings().resetToDefaultMappings();
|
||||
}
|
||||
|
||||
void buttonClicked (Button*) override
|
||||
{
|
||||
AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon,
|
||||
TRANS("Reset to defaults"),
|
||||
TRANS("Are you sure you want to reset all the key-mappings to their default state?"),
|
||||
TRANS("Reset"),
|
||||
String(),
|
||||
&owner,
|
||||
ModalCallbackFunction::forComponent (resetToDefaultsCallback, &owner));
|
||||
}
|
||||
|
||||
private:
|
||||
KeyMappingEditorComponent& owner;
|
||||
};
|
||||
|
||||
static void resetKeyMappingsToDefaultsCallback (int result, KeyMappingEditorComponent* owner)
|
||||
{
|
||||
if (result != 0 && owner != nullptr)
|
||||
owner->getMappings().resetToDefaultMappings();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
KeyMappingEditorComponent::KeyMappingEditorComponent (KeyPressMappingSet& mappingManager,
|
||||
|
|
@ -405,7 +392,16 @@ KeyMappingEditorComponent::KeyMappingEditorComponent (KeyPressMappingSet& mappin
|
|||
if (showResetToDefaultButton)
|
||||
{
|
||||
addAndMakeVisible (resetButton);
|
||||
resetButton.addListener (treeItem.get());
|
||||
|
||||
resetButton.onClick = [this]()
|
||||
{
|
||||
AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon,
|
||||
TRANS("Reset to defaults"),
|
||||
TRANS("Are you sure you want to reset all the key-mappings to their default state?"),
|
||||
TRANS("Reset"),
|
||||
{}, this,
|
||||
ModalCallbackFunction::forComponent (resetKeyMappingsToDefaultsCallback, this));
|
||||
};
|
||||
}
|
||||
|
||||
addAndMakeVisible (tree);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue