Opened 11 years ago

Last modified 22 months ago

#1651 reopened bug

[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: jackburton
Priority: normal Milestone: R1
Component: Kits/Interface Kit Version: R1/alpha3
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

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 11 years ago.
B_ALIGN_LEFT.png
B_ALIGN_RIGHT.png (62.3 KB) - added by oco 11 years ago.
B_ALIGN_RIGHT.png
TextDemo.cpp (1.1 KB) - added by Pete 7 years ago.
Demo source of SetAlignment bad behaviour
btextcontrol_centered.avi (1.1 MB) - added by humdinger 22 months ago.
Clipdinger's settings window BTextControl

Download all attachments as: .zip

Change History (13)

Changed 11 years ago by oco

Attachment: B_ALIGN_LEFT.png added

B_ALIGN_LEFT.png

Changed 11 years ago by oco

Attachment: B_ALIGN_RIGHT.png added

B_ALIGN_RIGHT.png

comment:1 Changed 11 years ago by axeld

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 Changed 11 years ago by jackburton

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

comment:3 Changed 11 years ago by jackburton

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 Changed 11 years ago by stippi

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.

Changed 7 years ago by Pete

Attachment: TextDemo.cpp added

Demo source of SetAlignment bad behaviour

comment:5 Changed 7 years ago by Pete

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 Changed 4 years ago by pulkomandy

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 Changed 22 months ago by humdinger

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.

Changed 22 months ago by humdinger

Attachment: btextcontrol_centered.avi added

Clipdinger's settings window BTextControl

comment:8 in reply to:  7 Changed 22 months ago by jackburton

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 Changed 22 months ago by humdinger

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

Note: See TracTickets for help on using tickets.