Browse Source

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

tags/2021-05-28
jules 11 years ago
parent
commit
ac8bc1a7b4
5 changed files with 25 additions and 11 deletions
  1. +2
    -0
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp
  2. +2
    -0
      modules/juce_gui_basics/widgets/juce_Label.cpp
  3. +8
    -4
      modules/juce_gui_basics/widgets/juce_Label.h
  4. +4
    -3
      modules/juce_gui_basics/widgets/juce_TextEditor.cpp
  5. +9
    -4
      modules/juce_gui_basics/widgets/juce_TextEditor.h

+ 2
- 0
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp 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;
}


+ 2
- 0
modules/juce_gui_basics/widgets/juce_Label.cpp 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();


+ 8
- 4
modules/juce_gui_basics/widgets/juce_Label.h 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;


+ 4
- 3
modules/juce_gui_basics/widgets/juce_TextEditor.cpp 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();


+ 9
- 4
modules/juce_gui_basics/widgets/juce_TextEditor.h 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);


Loading…
Cancel
Save