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

TextEditor: Avoid giving away keyboard focus unconditionally in destructor

While improving Android IME support (da38c1ed), text editor destructors
were updated to explicitly pass keyboard focus elsewhere.
As far as I remember, the change was intended to prevent the text input
system from trying to send input events to components while they were
being destroyed, in which case the TextInputTarget and Component bases
may be 'valid', but the data members referenced by the TextInputTarget
implementation may have been destroyed.

The motivation for removing these lines is that giving away focus and
sending a focus event can cause all components to become unfocused. This
is problematic in the case of slider text editors - pressing 'enter'
will cause the TextEditor to be destroyed, but the parent component will
fail to gain focus, so pressing 'tab' will not have any effect.
This commit is contained in:
reuk 2023-07-31 19:25:18 +01:00
parent 3387ca362c
commit e4b8569b12
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
4 changed files with 5 additions and 9 deletions

View file

@ -948,8 +948,6 @@ TextEditor::TextEditor (const String& name, juce_wchar passwordChar)
TextEditor::~TextEditor()
{
giveAwayKeyboardFocus();
if (auto* peer = getPeer())
peer->refreshTextInputTarget();

View file

@ -37,8 +37,8 @@ namespace juce
@tags{GUI}
*/
class JUCE_API TextEditor : public Component,
public TextInputTarget,
class JUCE_API TextEditor : public TextInputTarget,
public Component,
public SettableTooltipClient
{
public:

View file

@ -476,8 +476,6 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& doc, CodeTokeniser* cons
CodeEditorComponent::~CodeEditorComponent()
{
giveAwayKeyboardFocus();
if (auto* peer = getPeer())
peer->refreshTextInputTarget();

View file

@ -38,9 +38,9 @@ class CodeTokeniser;
@tags{GUI}
*/
class JUCE_API CodeEditorComponent : public Component,
public ApplicationCommandTarget,
public TextInputTarget
class JUCE_API CodeEditorComponent : public TextInputTarget,
public Component,
public ApplicationCommandTarget
{
public:
//==============================================================================