Opened 13 years ago

Closed 5 days ago

#1651 closed bug (fixed)

[BTextControl] When alignment is set to B_ALIGN_RIGHT, the text is not aligned to the right of the control

Reported by: oco Owned by:
Priority: normal Milestone: R1/beta3
Component: Kits/Interface Kit Version: R1/alpha3
Keywords: Cc:
Blocked By: Blocking:
Platform: All


When alignment is set to B_ALIGN_RIGHT, the text is not aligned to the right of the control. The text is only moved a few pixels to the right.

steps to reproduce : The BTextControl is created with BRect(10, 15, 150, 20). ResizingMode is set to B_FOLLOW_LEFT | B_FOLLOW_TOP. flags is set to B_WILL_DRAW | B_NAVIGABLE. Then SetDivider is called with 0. And SetAlignment is called with (B_ALIGN_LEFT, B_ALIGN_LEFT) first. See B_ALIGN_LEFT.png.

Then SetAlignment is called with (B_ALIGN_RIGHT, B_ALIGN_RIGHT). See B_ALIGN_RIGHT.png.

Attachments (4)

B_ALIGN_LEFT.png (55.7 KB ) - added by oco 13 years ago.
B_ALIGN_RIGHT.png (62.3 KB ) - added by oco 13 years ago.
TextDemo.cpp (1.1 KB ) - added by Pete 9 years ago.
Demo source of SetAlignment bad behaviour
btextcontrol_centered.avi (1.1 MB ) - added by humdinger 4 years ago.
Clipdinger's settings window BTextControl

Download all attachments as: .zip

Change History (16)

by oco, 13 years ago

Attachment: B_ALIGN_LEFT.png added


by oco, 13 years ago

Attachment: B_ALIGN_RIGHT.png added


comment:1 by axeld, 13 years ago

Owner: changed from axeld to jackburton

This is obviously a bug in BTextView (which is responsible for the text view inside the BTextControl).

comment:2 by jackburton, 13 years ago

Actually BTextInput::AlignTextRect() looks suspicious...

comment:3 by jackburton, 12 years ago

I haven't checked, but this bug could have been fixed by stippi's hrev24130, if not before. Can you check ? Or can you provide a test app ?

comment:4 by stippi, 12 years ago

Resolution: fixed
Status: newclosed

Oh yeah, I tested this when I worked on it and this works just fine now. Didn't know it was broken before my initial changes.

by Pete, 9 years ago

Attachment: TextDemo.cpp added

Demo source of SetAlignment bad behaviour

comment:5 by Pete, 9 years ago

Resolution: fixed
Status: closedreopened
Version: R1/pre-alpha1R1/alpha3

I'm reopening this, as the symptom seems to have resurfaced. Not sure if the cause is the same. I'm attaching a small test file (source) that shows the problems.

The test creates a window with a BTextView and a BTextControl, the first directly above the second, both with the alignment set to B_ALIGN_RIGHT. In BeOS, this works as expected: both the view and the control show text aligned at the right of their fields.

In Haiku (tested on hrev42415) things are not so right.

The BTextControl appears with the text left-aligned. The text in the BTextView directly above is not visible at all!

However, if you click the mouse in the region above the visible control, you can select the view. You don't see a cursor immediately, but type a left-arrow and it will appear. Then type right-arrows and the text will appear character by character at the right of the field. The text was initially aligned right out of range!

comment:6 by pulkomandy, 6 years ago

The original problem is fixed now (see #8391 / hrev48463) and BTextControl will work. However the BTextView in Pete's test still has the text out of view when it is shown, and I'm not sure there is a separate ticket tracking that.

comment:7 by humdinger, 4 years ago

Just to add, I experience an anomaly with a BTextControl with no label that should be center aligned. The code is a simple:

fLimitControl = new BTextControl("limitfield", NULL, "", NULL);
fLimitControl->SetAlignment(B_ALIGN_CENTER, B_ALIGN_CENTER);

and after that I do a bit of DisallowChar() to only allow numbers.

In the attached clip (slow playback as every BeScreenCapture capture...) I press backspace to delete the text "100". Note the cursor already isn' really centered. I then enter characters, the control behaves as if it left aligned, but inset a few dozen pixels. I then delete all characters and re-type them. The cursor now is completely at the left side, no sign of center...

This is a real-word example of Clipdinger's settings window, if anyone wants to reproduce.

by humdinger, 4 years ago

Attachment: btextcontrol_centered.avi added

Clipdinger's settings window BTextControl

in reply to:  7 comment:8 by jackburton, 4 years ago

Replying to humdinger:

In the attached clip (slow playback as every BeScreenCapture capture...) I press

Sorry to hijack the ticket... this should be fixed in v2.2

comment:9 by humdinger, 4 years ago

I created issue #8 at your bugtracker. We can take things from there.

comment:10 by AGMS, 4 months ago

May be releated to #12608 where BTextControl centering calculations are wrong.

comment:11 by jackburton, 4 months ago

Owner: jackburton removed
Status: reopenedassigned

comment:12 by pulkomandy, 5 days ago

Milestone: R1R1/beta3
Resolution: fixed
Status: assignedclosed

Fixed in hrev54496.

Note: See TracTickets for help on using tickets.