1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added methods to Label and TextEditor to specify the type of virtual keyboard they require.

This commit is contained in:
jules 2015-01-07 12:03:02 +00:00
parent dc79ef6094
commit ac8bc1a7b4
5 changed files with 25 additions and 11 deletions

View file

@ -1475,6 +1475,8 @@ Label* LookAndFeel_V2::createSliderTextBox (Slider& slider)
l->setColour (TextEditor::highlightColourId, slider.findColour (Slider::textBoxHighlightColourId));
l->setKeyboardType (TextInputTarget::numericKeyboard);
return l;
}

View file

@ -30,6 +30,7 @@ Label::Label (const String& name, const String& labelText)
justification (Justification::centredLeft),
border (1, 5, 1, 5),
minimumHorizontalScale (0.7f),
keyboardType (TextEditor::textKeyboard),
editSingleClick (false),
editDoubleClick (false),
lossOfFocusDiscardsChanges (false)
@ -208,6 +209,7 @@ void Label::showEditor()
{
addAndMakeVisible (editor = createEditorComponent());
editor->setText (getText(), false);
editor->setKeyboardType (keyboardType);
editor->addListener (this);
editor->grabKeyboardFocus();

View file

@ -117,7 +117,7 @@ public:
void setJustificationType (Justification justification);
/** Returns the type of justification, as set in setJustificationType(). */
Justification getJustificationType() const noexcept { return justification; }
Justification getJustificationType() const noexcept { return justification; }
/** Changes the border that is left between the edge of the component and the text.
By default there's a small gap left at the sides of the component to allow for
@ -126,7 +126,7 @@ public:
void setBorderSize (BorderSize<int> newBorderSize);
/** Returns the size of the border to be left around the text. */
BorderSize<int> getBorderSize() const noexcept { return border; }
BorderSize<int> getBorderSize() const noexcept { return border; }
/** Makes this label "stick to" another component.
@ -151,7 +151,7 @@ public:
Returns false if the label is above the other component. This is only relevent if
attachToComponent() has been called.
*/
bool isAttachedOnLeft() const noexcept { return leftOfOwnerComp; }
bool isAttachedOnLeft() const noexcept { return leftOfOwnerComp; }
/** Specifies the minimum amount that the font can be squashed horizontally before it starts
using ellipsis.
@ -161,7 +161,10 @@ public:
void setMinimumHorizontalScale (float newScale);
/** Specifies the amount that the font can be squashed horizontally. */
float getMinimumHorizontalScale() const noexcept { return minimumHorizontalScale; }
float getMinimumHorizontalScale() const noexcept { return minimumHorizontalScale; }
/** Set a keyboard type for use when the text editor is shown. */
void setKeyboardType (TextInputTarget::VirtualKeyboardType type) noexcept { keyboardType = type; }
//==============================================================================
/**
@ -331,6 +334,7 @@ private:
WeakReference<Component> ownerComponent;
BorderSize<int> border;
float minimumHorizontalScale;
TextInputTarget::VirtualKeyboardType keyboardType;
bool editSingleClick;
bool editDoubleClick;
bool lossOfFocusDiscardsChanges;

View file

@ -921,6 +921,7 @@ TextEditor::TextEditor (const String& name,
totalNumChars (0),
caretPosition (0),
passwordCharacter (passwordChar),
keyboardType (TextInputTarget::textKeyboard),
dragType (notDragging)
{
setOpaque (true);
@ -1292,8 +1293,8 @@ void TextEditor::moveCaret (int newCaretPos)
{
if (newCaretPos < 0)
newCaretPos = 0;
else if (newCaretPos > getTotalNumChars())
newCaretPos = getTotalNumChars();
else
newCaretPos = jmin (newCaretPos, getTotalNumChars());
if (newCaretPos != getCaretPosition())
{
@ -2128,7 +2129,7 @@ void TextEditor::enablementChanged()
repaint();
}
void TextEditor::setTemporaryUnderlining (const Array <Range<int> >& newUnderlinedSections)
void TextEditor::setTemporaryUnderlining (const Array<Range<int> >& newUnderlinedSections)
{
underlinedSections = newUnderlinedSections;
repaint();

View file

@ -569,7 +569,7 @@ public:
void setInputFilter (InputFilter* newFilter, bool takeOwnership);
/** Returns the current InputFilter, as set by setInputFilter(). */
InputFilter* getInputFilter() const noexcept { return inputFilter; }
InputFilter* getInputFilter() const noexcept { return inputFilter; }
/** Sets limits on the characters that can be entered.
This is just a shortcut that passes an instance of the LengthAndCharacterRestriction
@ -583,6 +583,8 @@ public:
void setInputRestrictions (int maxTextLength,
const String& allowedCharacters = String::empty);
void setKeyboardType (VirtualKeyboardType type) noexcept { keyboardType = type; }
//==============================================================================
/** This abstract base class is implemented by LookAndFeel classes to provide
TextEditor drawing functionality.
@ -631,7 +633,9 @@ public:
/** @internal */
bool isTextInputActive() const override;
/** @internal */
void setTemporaryUnderlining (const Array <Range<int> >&) override;
void setTemporaryUnderlining (const Array<Range<int> >&) override;
/** @internal */
VirtualKeyboardType getKeyboardType() override { return keyboardType; }
protected:
//==============================================================================
@ -692,6 +696,7 @@ private:
juce_wchar passwordCharacter;
OptionalScopedPointer<InputFilter> inputFilter;
Value textValue;
VirtualKeyboardType keyboardType;
enum
{
@ -700,8 +705,8 @@ private:
draggingSelectionEnd
} dragType;
ListenerList <Listener> listeners;
Array <Range<int> > underlinedSections;
ListenerList<Listener> listeners;
Array<Range<int> > underlinedSections;
void moveCaret (int newCaretPos);
void moveCaretTo (int newPosition, bool isSelecting);