|
|
@@ -31,13 +31,13 @@ class TextPropertyComponent::LabelComp : public Label, |
|
|
public FileDragAndDropTarget
|
|
|
public FileDragAndDropTarget
|
|
|
{
|
|
|
{
|
|
|
public:
|
|
|
public:
|
|
|
LabelComp (TextPropertyComponent& tpc, const int charLimit, const bool multiline)
|
|
|
|
|
|
|
|
|
LabelComp (TextPropertyComponent& tpc, int charLimit, bool multiline, bool editable)
|
|
|
: Label (String(), String()),
|
|
|
: Label (String(), String()),
|
|
|
owner (tpc),
|
|
|
owner (tpc),
|
|
|
maxChars (charLimit),
|
|
|
maxChars (charLimit),
|
|
|
isMultiline (multiline)
|
|
|
isMultiline (multiline)
|
|
|
{
|
|
|
{
|
|
|
setEditable (true, true, false);
|
|
|
|
|
|
|
|
|
setEditable (editable, editable);
|
|
|
|
|
|
|
|
|
updateColours();
|
|
|
updateColours();
|
|
|
}
|
|
|
}
|
|
|
@@ -55,7 +55,7 @@ public: |
|
|
|
|
|
|
|
|
TextEditor* createEditorComponent() override
|
|
|
TextEditor* createEditorComponent() override
|
|
|
{
|
|
|
{
|
|
|
TextEditor* const ed = Label::createEditorComponent();
|
|
|
|
|
|
|
|
|
auto* ed = Label::createEditorComponent();
|
|
|
ed->setInputRestrictions (maxChars);
|
|
|
ed->setInputRestrictions (maxChars);
|
|
|
|
|
|
|
|
|
if (isMultiline)
|
|
|
if (isMultiline)
|
|
|
@@ -94,20 +94,22 @@ private: |
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
//==============================================================================
|
|
|
TextPropertyComponent::TextPropertyComponent (const String& name,
|
|
|
TextPropertyComponent::TextPropertyComponent (const String& name,
|
|
|
const int maxNumChars,
|
|
|
|
|
|
const bool isMultiLine)
|
|
|
|
|
|
|
|
|
int maxNumChars,
|
|
|
|
|
|
bool isMultiLine,
|
|
|
|
|
|
bool isEditable)
|
|
|
: PropertyComponent (name)
|
|
|
: PropertyComponent (name)
|
|
|
{
|
|
|
{
|
|
|
createEditor (maxNumChars, isMultiLine);
|
|
|
|
|
|
|
|
|
createEditor (maxNumChars, isMultiLine, isEditable);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
TextPropertyComponent::TextPropertyComponent (const Value& valueToControl,
|
|
|
TextPropertyComponent::TextPropertyComponent (const Value& valueToControl,
|
|
|
const String& name,
|
|
|
const String& name,
|
|
|
const int maxNumChars,
|
|
|
|
|
|
const bool isMultiLine)
|
|
|
|
|
|
|
|
|
int maxNumChars,
|
|
|
|
|
|
bool isMultiLine,
|
|
|
|
|
|
bool isEditable)
|
|
|
: PropertyComponent (name)
|
|
|
: PropertyComponent (name)
|
|
|
{
|
|
|
{
|
|
|
createEditor (maxNumChars, isMultiLine);
|
|
|
|
|
|
|
|
|
createEditor (maxNumChars, isMultiLine, isEditable);
|
|
|
|
|
|
|
|
|
textEditor->getTextValue().referTo (valueToControl);
|
|
|
textEditor->getTextValue().referTo (valueToControl);
|
|
|
}
|
|
|
}
|
|
|
@@ -131,9 +133,9 @@ Value& TextPropertyComponent::getValue() const |
|
|
return textEditor->getTextValue();
|
|
|
return textEditor->getTextValue();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void TextPropertyComponent::createEditor (const int maxNumChars, const bool isMultiLine)
|
|
|
|
|
|
|
|
|
void TextPropertyComponent::createEditor (int maxNumChars, bool isMultiLine, bool isEditable)
|
|
|
{
|
|
|
{
|
|
|
addAndMakeVisible (textEditor = new LabelComp (*this, maxNumChars, isMultiLine));
|
|
|
|
|
|
|
|
|
addAndMakeVisible (textEditor = new LabelComp (*this, maxNumChars, isMultiLine, isEditable));
|
|
|
|
|
|
|
|
|
if (isMultiLine)
|
|
|
if (isMultiLine)
|
|
|
{
|
|
|
{
|
|
|
@@ -149,7 +151,7 @@ void TextPropertyComponent::refresh() |
|
|
|
|
|
|
|
|
void TextPropertyComponent::textWasEdited()
|
|
|
void TextPropertyComponent::textWasEdited()
|
|
|
{
|
|
|
{
|
|
|
const String newText (textEditor->getText());
|
|
|
|
|
|
|
|
|
auto newText = textEditor->getText();
|
|
|
|
|
|
|
|
|
if (getText() != newText)
|
|
|
if (getText() != newText)
|
|
|
setText (newText);
|
|
|
setText (newText);
|
|
|
@@ -185,4 +187,10 @@ void TextPropertyComponent::setInterestedInFileDrag (bool isInterested) |
|
|
textEditor->setInterestedInFileDrag (isInterested);
|
|
|
textEditor->setInterestedInFileDrag (isInterested);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TextPropertyComponent::setEditable (bool isEditable)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (textEditor != nullptr)
|
|
|
|
|
|
textEditor->setEditable (isEditable, isEditable);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
} // namespace juce
|
|
|
} // namespace juce
|