lalala
July 21, 2016, 4:05pm
1
The caret width is hardcoded to 2 :
void CaretComponent::setCaretPosition (const Rectangle<int>& characterArea)
{
startTimer (380);
setVisible (shouldBeShown());
setBounds (characterArea.withWidth (2));
}
But it is waaaaaay much more sexy with 1 !
(perhaps it can also be useful to make it thicker, terminal-like)
Edit : oh, it’s a virtual method actually "You can override this method to customise its size."
2 Likes
I’d still like, for simplicity, a method in CaretComponent to set the caret width.
Rail
jimc
May 1, 2019, 11:04am
3
I’d like this too.
It’s a right maze. TextEditor->LookAndFeel->createCaretComponent just to set the width.
I agree, a setCaretWidth() or something would be much better.
I actually just needed this again just 2 days ago! Here is the code to put in the lookAndFeel (for an hardcoded width of 1) :
struct ThinnerCaretComponent : public CaretComponent
{
using CaretComponent::CaretComponent;
void setCaretPosition (const juce::Rectangle<int>& characterArea) override
{
CaretComponent::setCaretPosition (characterArea);
setBounds (characterArea.withWidth (1));
}
};
CaretComponent* createCaretComponent (Component* keyFocusOwner) override
{
return new ThinnerCaretComponent (keyFocusOwner);
}
2 Likes