littleflylongbow / guichan

Automatically exported from code.google.com/p/guichan
Other
0 stars 0 forks source link

TextBox always has 1 row. #129

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This is actually a 2 parter (but the first is quick, I promise!)  In 
looking at the TextBox code, I see in the constructors that adjustSize() 
is called right after setText().  As setText() calls adjustSize(), this 
makes the second call redundant.

The second, more subtle issue, is that even if there is no text it will 
always have at least 1 row.  I feel that this is not expected behavior 
because if there is no text present for it to display, I would not think 
that it should have any rows.

For example, if you create a default TextBox (or even a TextBox as: 
TextBox box("")), then there are no characters in the string for the box 
to display, yet a call to getNumberOfRows() will return a result of 1.

The problem lies in the setText() method itself and that it runs a do 
while loop (so a first row is always generated).  I've attached an altered 
version that compensates for blank text strings.

As a final thought, could I throw out a suggestion to save code space and 
create just one constructor for a TextBox with a default parameter of a 
blank string (ex: TextBox(const std::string& text = ""))  This would 
remove the need for a second, default, constructor.

Original issue reported on code.google.com by holy.smo...@gmail.com on 22 Jan 2010 at 3:26

Attachments:

GoogleCodeExporter commented 8 years ago
Sounds like you have good points. I'll apply the patch as soon as possible.

Original comment by olof.nae...@gmail.com on 30 Jan 2010 at 12:17