diff --git a/panda/src/gui/guiBehavior.cxx b/panda/src/gui/guiBehavior.cxx index 53f881ef55..9733d3832f 100644 --- a/panda/src/gui/guiBehavior.cxx +++ b/panda/src/gui/guiBehavior.cxx @@ -17,7 +17,8 @@ void GuiBehavior::BehaviorFunctor::doit(GuiBehavior*) { } GuiBehavior::GuiBehavior(const string& name) : GuiItem(name), - _eh((EventHandler*)0L) { + _eh((EventHandler*)0L), + _behavior_running(false) { } GuiBehavior::~GuiBehavior(void) { diff --git a/panda/src/gui/guiButton.cxx b/panda/src/gui/guiButton.cxx index 85233721e4..991166e02e 100644 --- a/panda/src/gui/guiButton.cxx +++ b/panda/src/gui/guiButton.cxx @@ -450,6 +450,8 @@ void GuiButton::start_behavior(void) { GuiBehavior::start_behavior(); if (_mgr == (GuiManager*)0L) return; + if (!this->is_active()) + return; _eh->add_hook(_down_event, GuiButton::behavior_down, (void*)this); _eh->add_hook(_down_rollover_event, GuiButton::behavior_down, (void*)this); } diff --git a/panda/src/gui/guiChooser.cxx b/panda/src/gui/guiChooser.cxx index 5a081efefe..2828f3f0e5 100644 --- a/panda/src/gui/guiChooser.cxx +++ b/panda/src/gui/guiChooser.cxx @@ -16,9 +16,9 @@ GuiChooser::ChooseFunctor::~ChooseFunctor(void) { } void GuiChooser::ChooseFunctor::doit(GuiBehavior* b) { - if (b == this->_ch->_prev_button) + if ((b == this->_ch->_prev_button) && this->_ch->_prev_button->is_active()) this->_ch->move_prev(); - if (b == this->_ch->_next_button) + if ((b == this->_ch->_next_button) && this->_ch->_next_button->is_active()) this->_ch->move_next(); } @@ -50,13 +50,23 @@ void GuiChooser::move_prev(void) { _items[tmp]->manage(_mgr, *_eh); if (tmp == 0) _prev_button->inactive(); - else + else { _prev_button->up(); + if (_behavior_running) { + _prev_button->start_behavior(); + _prev_button->set_behavior_functor(_prev_functor); + } + } int foo = _items.size() - 1; if (tmp == foo) _next_button->inactive(); - else + else { _next_button->up(); + if (_behavior_running) { + _next_button->start_behavior(); + _next_button->set_behavior_functor(_next_functor); + } + } } _curr = tmp; } @@ -77,12 +87,23 @@ void GuiChooser::move_next(void) { _items[tmp]->manage(_mgr, *_eh); if (tmp == 0) _prev_button->inactive(); - else + else { _prev_button->up(); - if (tmp == (_items.size() - 1)) + if (_behavior_running) { + _prev_button->start_behavior(); + _prev_button->set_behavior_functor(_prev_functor); + } + } + int foo = _items.size() - 1; + if (tmp == foo) _next_button->inactive(); - else + else { _next_button->up(); + if (_behavior_running) { + _next_button->start_behavior(); + _next_button->set_behavior_functor(_next_functor); + } + } } _curr = tmp; }