1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

Use lambda callbacks instead of listeners with Slider, Button, Label, ComboBox and TextEditor classes

This commit is contained in:
Noah Dayan 2018-01-18 15:23:23 +00:00
parent 6d8d90e9d8
commit e690350df3
30 changed files with 114 additions and 258 deletions

View file

@ -344,8 +344,7 @@ void GenericCodeEditorComponent::removeListener (GenericCodeEditorComponent::Lis
}
//==============================================================================
class GenericCodeEditorComponent::FindPanel : public Component,
private TextEditor::Listener
class GenericCodeEditorComponent::FindPanel : public Component
{
public:
FindPanel()
@ -376,7 +375,13 @@ public:
findNext.setWantsKeyboardFocus (false);
editor.setText (getSearchString());
editor.addListener (this);
editor.onTextChange = [this] { changeSearchString(); };
editor.onReturnKey = [this] { ProjucerApplication::getCommandManager().invokeDirectly (CommandIDs::findNext, true); };
editor.onEscapeKey = [this]
{
if (GenericCodeEditorComponent* ed = getOwner())
ed->hideFindPanel();
};
}
void setCommandManager (ApplicationCommandManager* cm)
@ -406,7 +411,7 @@ public:
findPrev.setBounds (getWidth() - 70, y, 30, 22);
}
void textEditorTextChanged (TextEditor&) override
void changeSearchString()
{
setSearchString (editor.getText());
@ -414,19 +419,6 @@ public:
ed->findNext (true, false);
}
void textEditorFocusLost (TextEditor&) override {}
void textEditorReturnKeyPressed (TextEditor&) override
{
ProjucerApplication::getCommandManager().invokeDirectly (CommandIDs::findNext, true);
}
void textEditorEscapeKeyPressed (TextEditor&) override
{
if (GenericCodeEditorComponent* ed = getOwner())
ed->hideFindPanel();
}
GenericCodeEditorComponent* getOwner() const
{
return findParentComponentOfClass <GenericCodeEditorComponent>();