DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR Active] Link: http://www.fltk.org/str.php?L2889 Version: 1.3.1 Fixed in Subversion repository. The way the example was designed, SetSize() was intended to be called only once, but it would definitely increase usability if it called clear() so that it can be called more than once, so I've added it to svn r9728. So not a bug, but adding the clear() would improve the code for other purposes. But in actual practice if I were doing what you're doing (adding a new row), I'd create a new method called AddRow() and move the relevant code from SetSize() to that method, and then have SetSize() call AddRow() in the row loop to add the new rows. This way you can add new rows without recreating all the widgets. So for instance, rewriting the two methods this way would be better for your use case (I didn't heavily test the following, but it seems to work; it should guide you in the right direction anyway) ---------------------------------------------------------- void AddRow() { int r = rows(); begin(); // start adding widgets to group for ( int c = 0; c<cols(); c++ ) { int X,Y,W,H; find_cell(CONTEXT_TABLE, r, c, X, Y, W, H); char s[40]; if ( c & 1 ) { // Create the input widgets sprintf(s, "%d.%d", r, c); Fl_Input *in = new Fl_Input(X,Y,W,H); in->value(s); } else { // Create the light buttons sprintf(s, "%d/%d ", r, c); Fl_Light_Button *butt = new Fl_Light_Button(X,Y,W,H,strdup(s)); butt->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); butt->callback(button_cb, (void*)this); butt->value( ((r+c*2) & 4 ) ? 1 : 0); } } end(); rows(rows()+1); } void SetSize(int newrows, int newcols) { clear(); // clear child widgets (if any) rows(0); cols(newcols); for ( int r = 0; r<newrows; r++ ) { AddRow(); } } ---------------------------------------------------------- Then in your button callback, just call G_Table->AddRow(). In the interest of keeping the example simple though, I'd rather not change the example beyond adding the clear() you mentioned; while the above increases usability for purposes beyond the example, it makes the code harder to comprehend I think, as it is solving problems not shown by the example. Leaving this open to see your reply, and will then close. Link: http://www.fltk.org/str.php?L2889 Version: 1.3.1 _______________________________________________ fltk-bugs mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-bugs
