1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-17 00:44:19 +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

@ -132,8 +132,7 @@ Component* JucerTreeViewBase::createItemComponent()
}
//==============================================================================
class RenameTreeItemCallback : public ModalComponentManager::Callback,
public TextEditor::Listener
class RenameTreeItemCallback : public ModalComponentManager::Callback
{
public:
RenameTreeItemCallback (JucerTreeViewBase& ti, Component& parent, const Rectangle<int>& bounds)
@ -143,7 +142,9 @@ public:
ed.setPopupMenuEnabled (false);
ed.setSelectAllWhenFocused (true);
ed.setFont (item.getFont());
ed.addListener (this);
ed.onReturnKey = [this] { ed.exitModalState (1); };
ed.onEscapeKey = [this] { ed.exitModalState (0); };
ed.onFocusLost = [this] { ed.exitModalState (0); };
ed.setText (item.getRenamingName());
ed.setBounds (bounds);
@ -157,11 +158,6 @@ public:
item.setName (ed.getText());
}
void textEditorTextChanged (TextEditor&) override {}
void textEditorReturnKeyPressed (TextEditor& editor) override { editor.exitModalState (1); }
void textEditorEscapeKeyPressed (TextEditor& editor) override { editor.exitModalState (0); }
void textEditorFocusLost (TextEditor& editor) override { editor.exitModalState (0); }
private:
struct RenameEditor : public TextEditor
{