[openbeos] BTextControl Question
- From: "Travis Beaty" <travis_beaty@xxxxxxxxxxxxx>
- To: openbeos@xxxxxxxxxxxxx
- Date: Tue, 29 Jan 2002 20:46:16 -0700
Hello All!
I'm a newbie BeOS programmer (well, actually, OBOS programmer now!), and I'm
also fairly new to
programming in C++.
As a "starter" project for learning BeOS programming, I've decided to create a
Polish notation calculator. Part
of this calculator consists of four "banks," which hold values to be
manipulated by the calculator. The bottom
bank, "W," should be editable, so that the user can enter values (like a normal
calculator). The remainder of
the banks may not be edited by the user.
I've decided to implement the bank displays with BTextControls. In Windows
(sorry I'm being obscene on the
list, hehehe), I'd like to give the text controls the ES_READONLY flag. This
is how I've tried to do it in my code,
using BTextView :: MakeEditable():
// START OF CODE
BTextControl
*bank_display[4];
// (A field within the parent window's class).
// Excerpts from the parent window's class constructor ...
// labels for the bank displays.
const char
bank_lbl[4][3] = {"Z:", "Y:", "X:", "W:"};
// Location of next bank display control and reset button.
BRect
bank_rect(5, 28, 155, 20),
button_rect(160, 25, 220, 20);
// ...
for(int i = 0; i < 4; i++) {
// Build a bank display TextControl and initialize it.
bank_display[i] = new BTextControl(
bank_rect, NULL, bank_lbl[i], "Hello!", new BMessage(-1),
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
bank_display[i]->SetDivider(20);
bank_display[i]->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
if(i != 3) bank_display[i]->TextView()->MakeEditable(false);
// Increment the top and bottom members of bank_rect to set the
// values up for the next control.
bank_rect.top += 25;
bank_rect.bottom += 25;
}
(Sorry if the formatting is messed up ... I have a bad problem with my code
getting scrambled somewhere
between my computer and your computer.)
Unfortunately, when running the application, all text controls are still
editable, and the call to MakeEditable()
does not appear to have any affect. However, the calls to SetDivider() and
SetAlignment() appear to work as
advertised. This is either due to my lack of knowledge concerning the BeOS
API, my lack of knowledge
concerning C++, or a hideous combination of the two.
Any help would be greatly appreciated.
Travis Beaty
Evans, Colorado.
Other related posts: