mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Don't repeatedly set the wantsFocus flag if it hasn't changed
This commit is contained in:
parent
962cfc7aff
commit
a258295481
2 changed files with 21 additions and 3 deletions
|
|
@ -46,7 +46,8 @@ ComboBox::ComboBox (const String& name)
|
|||
menuActive (false),
|
||||
scrollWheelEnabled (false),
|
||||
mouseWheelAccumulator (0),
|
||||
noChoicesMessage (TRANS("(no choices)"))
|
||||
noChoicesMessage (TRANS("(no choices)")),
|
||||
labelEditableState (editableUnknown)
|
||||
{
|
||||
setRepaintsOnMouseActivity (true);
|
||||
lookAndFeelChanged();
|
||||
|
|
@ -66,7 +67,9 @@ void ComboBox::setEditableText (const bool isEditable)
|
|||
if (label->isEditableOnSingleClick() != isEditable || label->isEditableOnDoubleClick() != isEditable)
|
||||
{
|
||||
label->setEditable (isEditable, isEditable, false);
|
||||
setWantsKeyboardFocus (! isEditable);
|
||||
labelEditableState = (isEditable ? labelIsEditable : labelIsNotEditable);
|
||||
|
||||
setWantsKeyboardFocus (labelEditableState == labelIsNotEditable);
|
||||
resized();
|
||||
}
|
||||
}
|
||||
|
|
@ -437,7 +440,14 @@ void ComboBox::lookAndFeelChanged()
|
|||
}
|
||||
|
||||
addAndMakeVisible (label);
|
||||
setWantsKeyboardFocus (! label->isEditable());
|
||||
|
||||
EditableState newEditableState = (label->isEditable() ? labelIsEditable : labelIsNotEditable);
|
||||
|
||||
if (newEditableState != labelEditableState)
|
||||
{
|
||||
labelEditableState = newEditableState;
|
||||
setWantsKeyboardFocus (labelEditableState == labelIsNotEditable);
|
||||
}
|
||||
|
||||
label->addListener (this);
|
||||
label->addMouseListener (this, false);
|
||||
|
|
|
|||
|
|
@ -427,6 +427,13 @@ private:
|
|||
bool isEnabled : 1, isHeading : 1;
|
||||
};
|
||||
|
||||
enum EditableState
|
||||
{
|
||||
editableUnknown,
|
||||
labelIsNotEditable,
|
||||
labelIsEditable
|
||||
};
|
||||
|
||||
OwnedArray<ItemInfo> items;
|
||||
Value currentId;
|
||||
int lastCurrentId;
|
||||
|
|
@ -435,6 +442,7 @@ private:
|
|||
ListenerList<Listener> listeners;
|
||||
ScopedPointer<Label> label;
|
||||
String textWhenNothingSelected, noChoicesMessage;
|
||||
EditableState labelEditableState;
|
||||
|
||||
ItemInfo* getItemForId (int) const noexcept;
|
||||
ItemInfo* getItemForIndex (int) const noexcept;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue