[haiku-bugs] [Haiku] #15189: BTextControl right alignment error

  • From: "Haiku" <trac@xxxxxxxxxxxx>
  • To: undisclosed-recipients: ;
  • Date: Fri, 19 Jul 2019 17:02:59 -0000

#15189: BTextControl right alignment error
-----------------------+------------------------------
 Reporter:  telephil   |        Owner:  nobody
     Type:  bug        |       Status:  new
 Priority:  low        |    Milestone:  Unscheduled
Component:  - General  |      Version:  R1/Development
 Keywords:             |   Blocked By:
 Blocking:             |  Has a Patch:  0
 Platform:  All        |
-----------------------+------------------------------
 When using right content alignment for BTextControl and setting the text
 programmatically, the text overflows the control and only the first
 characters are visible.
 It is possible to have all the text visible by moving to the right with
 the right arrow though.
 Another bug arises when deleting the text afterward. The cursor is then
 blocked at the position of the first character instead of being on the
 right of the control.

 Attached screenshots highlight these 2 issues:
 - Text not fully displayed
 - Cursor position once text is deleted

 Here is a sample showing the first bug:

 {{{
 #!c++
 #include <Application.h>
 #include <Window.h>
 #include <TextControl.h>

 class SampleWindow : public BWindow
 {
 public:
         SampleWindow(void)
                 : BWindow(BRect(100, 100, 400, 150), "Sample",
 B_TITLED_WINDOW, 0)
         {
                 BTextControl *ctl = new BTextControl(BRect(4, 4, 250, 50),
 NULL,
 "Text", "", new BMessage('ctl'));
                 ctl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
                 ctl->SetText("hello");
                 AddChild(ctl);
         }

         bool QuitRequested()
         {
                 be_app->PostMessage(B_QUIT_REQUESTED);
                 return true;
         }
 };

 int
 main(void)
 {
         BApplication app("application/x-vnd.sample");
         SampleWindow *win = new SampleWindow;
         win->Show();
         app.Run();
         return EXIT_SUCCESS;
 }

 }}}

-- 
Ticket URL: <https://dev.haiku-os.org/ticket/15189>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.

Other related posts: