diff options
| -rw-r--r-- | src/Fl_Grid.cxx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Fl_Grid.cxx b/src/Fl_Grid.cxx index 66991345d..2952badc3 100644 --- a/src/Fl_Grid.cxx +++ b/src/Fl_Grid.cxx @@ -773,6 +773,9 @@ Fl_Grid::Cell *Fl_Grid::widget(Fl_Widget *wi, int row, int col, Fl_Grid_Align al assigned to another widget that widget is deassigned but kept as a child of the group. + Before you can assign a widget to a cell it must have been created as + a child of the Fl_Grid widget (i.e. its Fl_Group). + \param[in] wi widget to be assigned to the cell \param[in] row row \param[in] col column @@ -781,10 +784,15 @@ Fl_Grid::Cell *Fl_Grid::widget(Fl_Widget *wi, int row, int col, Fl_Grid_Align al \param[in] align widget alignment inside the cell \return assigned cell - \retval NULL if \p row or \p col is out of bounds + \retval NULL if \p row or \p col is out of bounds or \p wi is not a child */ Fl_Grid::Cell *Fl_Grid::widget(Fl_Widget *wi, int row, int col, int rowspan, int colspan, Fl_Grid_Align align) { + int child = Fl_Group::find(wi); // is this widget one of our children? + if (child >= children()) { + // fprintf(stderr, "Fl_Grid::widget(): can't assign widget %p to cell (%d, %d): not a child!\n", wi, row, col); + return 0; + } if (row < 0 || row > rows_) return 0; if (col < 0 || col > cols_) |
