diff --git a/source/gui/gbutton.h b/source/gui/gbutton.h index c11c4a051..6c9201921 100644 --- a/source/gui/gbutton.h +++ b/source/gui/gbutton.h @@ -43,6 +43,10 @@ public: virtual void think(int _frames); +protected: + virtual int isSelectable() {return true;} + + private: int *m_target; int *m_data; diff --git a/source/gui/gframe.cpp b/source/gui/gframe.cpp index 7719c1a18..1816bc9ce 100644 --- a/source/gui/gframe.cpp +++ b/source/gui/gframe.cpp @@ -85,6 +85,33 @@ void CGUIGroupFrame::clearFlags(GUI_FLAGS _flags) } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CGUIGroupFrame::isSelectable() +{ + CGUIObject *pGUI; + int selectable=false; + + pGUI=getChild(); + while(pGUI) + { + if(pGUI->isSelectable()) + { + selectable=true; + break; + } + pGUI=pGUI->getNext(); + } + +GUI_DBGMSG("frame is %s",selectable?"SELECTABLE":"NOT SELECTABLE"); + return selectable; +} + + @@ -118,9 +145,12 @@ void CGUIControlFrame::think(int _frames) pGUI->unselect(); GUI_DBGMSG("unselected %d",pGUI->getId()); - // Find next object and select it - pGUI=pGUI->getNext(); - if(!pGUI)pGUI=getChild(); + // Find next selectbale object and select it + while(!pGUI->isSelectable()) + { + pGUI=pGUI->getNext(); + if(!pGUI)pGUI=getChild(); + } pGUI->select(); GUI_DBGMSG("selected %d",pGUI->getId()); } @@ -181,10 +211,12 @@ void CGUIControlFrame::selectFrame() CGUIObject *pGUI; pGUI=getChild(); - if(pGUI) + while(!pGUI->isSelectable()) { - pGUI->select(); + ASSERT(pGUI); + pGUI=pGUI->getNext(); } + pGUI->select(); } diff --git a/source/gui/gframe.h b/source/gui/gframe.h index a82ff887c..e4f54db6f 100644 --- a/source/gui/gframe.h +++ b/source/gui/gframe.h @@ -40,7 +40,9 @@ public: virtual void setFlags(GUI_FLAGS _flags); virtual void clearFlags(GUI_FLAGS _flags); + virtual int isSelectable(); + protected: GUI_FLAGS getInitialFlags() {return FLAG_DRAWBORDER;} diff --git a/source/gui/gui.h b/source/gui/gui.h index 7d4910229..4ccb02506 100644 --- a/source/gui/gui.h +++ b/source/gui/gui.h @@ -78,6 +78,7 @@ public: CGUIObject *getChild() {return m_child;} CGUIObject *getNext() {return m_next;} + virtual int isSelectable() {return false;} int getId() {return m_id;} @@ -85,7 +86,6 @@ protected: virtual void recalc(); virtual GUI_FLAGS getInitialFlags() {return FLAG_NONE;} - virtual int isSelectable() {return false;} int getX() {return m_x;} int getY() {return m_y;}