Ticket #13796: 0002-TextInput-Fix-text-alignment-when-typing-or-removing.patch

File 0002-TextInput-Fix-text-alignment-when-typing-or-removing.patch, 997 bytes (added by hyche, 7 years ago)
  • src/kits/interface/TextInput.cpp

    From cce473f025b3c75b662b28f93fa6120063f27832 Mon Sep 17 00:00:00 2001
    From: hy che <cvghy116@gmail.com>
    Date: Fri, 24 Nov 2017 19:43:02 +0100
    Subject: [PATCH 2/2] TextInput: Fix text alignment when typing or removing.
    
    Align when it is B_ALIGN_RIGHT or text width is smaller than bounding width, it doesn't
    align with B_ALIGN_LEFT as it is the default behavior.
    
    Refix #13796
    ---
     src/kits/interface/TextInput.cpp | 5 ++++-
     1 file changed, 4 insertions(+), 1 deletion(-)
    
    diff --git a/src/kits/interface/TextInput.cpp b/src/kits/interface/TextInput.cpp
    index d744595..3dda891 100644
    a b _BTextInput_::KeyDown(const char* bytes, int32 numBytes)  
    116116
    117117        default:
    118118            BTextView::KeyDown(bytes, numBytes);
    119             AlignTextRect();
     119            if (Alignment() == B_ALIGN_LEFT)
     120                break;
     121            if (Alignment() == B_ALIGN_RIGHT || TextRect().Width() <= Bounds().Width())
     122                AlignTextRect();
    120123            break;
    121124    }
    122125}