mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Recreate CaretComponent correctly in CodeEditorComponent::lookAndFeelChanged()
This commit is contained in:
parent
5b432431fd
commit
bcb85bc752
1 changed files with 9 additions and 5 deletions
|
|
@ -348,9 +348,6 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& doc, CodeTokeniser* cons
|
|||
setMouseCursor (MouseCursor::IBeamCursor);
|
||||
setWantsKeyboardFocus (true);
|
||||
|
||||
lookAndFeelChanged();
|
||||
addAndMakeVisible (caret.get());
|
||||
|
||||
addAndMakeVisible (verticalScrollBar);
|
||||
verticalScrollBar.setSingleStepSize (1.0);
|
||||
|
||||
|
|
@ -369,6 +366,8 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& doc, CodeTokeniser* cons
|
|||
verticalScrollBar.addListener (pimpl.get());
|
||||
horizontalScrollBar.addListener (pimpl.get());
|
||||
document.addListener (pimpl.get());
|
||||
|
||||
lookAndFeelChanged();
|
||||
}
|
||||
|
||||
CodeEditorComponent::~CodeEditorComponent()
|
||||
|
|
@ -405,7 +404,10 @@ void CodeEditorComponent::setTemporaryUnderlining (const Array<Range<int>>&)
|
|||
|
||||
Rectangle<int> CodeEditorComponent::getCaretRectangle()
|
||||
{
|
||||
return getLocalArea (caret.get(), caret->getLocalBounds());
|
||||
if (caret != nullptr)
|
||||
return getLocalArea (caret.get(), caret->getLocalBounds());
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void CodeEditorComponent::setLineNumbersShown (const bool shouldBeShown)
|
||||
|
|
@ -582,7 +584,8 @@ void CodeEditorComponent::retokenise (int startIndex, int endIndex)
|
|||
//==============================================================================
|
||||
void CodeEditorComponent::updateCaretPosition()
|
||||
{
|
||||
caret->setCaretPosition (getCharacterBounds (getCaretPos()));
|
||||
if (caret != nullptr)
|
||||
caret->setCaretPosition (getCharacterBounds (getCaretPos()));
|
||||
}
|
||||
|
||||
void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, const bool highlighting)
|
||||
|
|
@ -1318,6 +1321,7 @@ bool CodeEditorComponent::perform (const InvocationInfo& info)
|
|||
void CodeEditorComponent::lookAndFeelChanged()
|
||||
{
|
||||
caret.reset (getLookAndFeel().createCaretComponent (this));
|
||||
addAndMakeVisible (*caret);
|
||||
}
|
||||
|
||||
bool CodeEditorComponent::performCommand (const CommandID commandID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue