diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2022-11-20 14:11:19 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2022-11-20 14:11:19 +0100 |
| commit | be928430a6cc642b82bc1dfe6a94823ae0dd5016 (patch) | |
| tree | 99ce8a1eefd47433a9f676c7fbccf245d3385a13 /src/Fl_Group.cxx | |
| parent | 8a53fc96117de38cc63515ff2e94d435184dbe9e (diff) | |
Fix Fl_Group::insert() and Fl_Scroll::on_move()
Diffstat (limited to 'src/Fl_Group.cxx')
| -rw-r--r-- | src/Fl_Group.cxx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx index f9bbcb541..a492a6ac9 100644 --- a/src/Fl_Group.cxx +++ b/src/Fl_Group.cxx @@ -513,8 +513,11 @@ void Fl_Group::insert(Fl_Widget &o, int index) { if (g == this) { // avoid expensive remove() and add() if we just move a widget within the group index = on_move(n, index); - if ((index == n) || (index < 0)) return; // this includes (children_ == 1) - if (index >= children_) index = children_ - 1; + if (index < 0) return; // don't move: requested by subclass + if (index > children_) + index = children_; + if (index > n) index--; // compensate for removal and re-insertion + if (index == n) return; // same position; this includes (children_ == 1) if (index > n) memmove(array_+n, array_+(n+1), (index-n) * sizeof(Fl_Widget*)); else |
