title: Element Manager needs help making specific elements top
body: <p>I am trying to make an element system for my GUI, but I have a problem!</p>
  
  <p>I am calling <code>CBaseElement::MakeTop()</code> every time a mouseclick has been detected inside a window</p>
  
  <pre><code>void CBaseElement::MakeTop()
  {
      int nSize = g_pElementList.size();
  
      for (int iIndex = 0; iIndex &lt; nSize; iIndex++)
      {
          CBaseElement* pNode = g_pElementList[iIndex];
          if (pNode == this)
          {
              g_pElementList.erase(g_pElementList.begin() + iIndex);
              g_pElementList.push_back(this);
  
              break;
          }
      }
  }
  </code></pre>
  
  <p>But how do I let the cursor element be the last to be rendered and the tooltip to be second?
  I have did this method:</p>
  
  <pre><code>void CBaseElement::MakeTop()
  {
      int nSize = g_pElementList.size();
  
      for (int iIndex = 0; iIndex &lt; nSize; iIndex++)
      {
          CBaseElement* pNode = g_pElementList[iIndex];
          if (pNode == this)
          {
              g_pElementList.erase(g_pElementList.begin() + iIndex);
              g_pElementList.push_back(this);
  
              for (int iIndex2 = 0; iIndex2 &lt; nSize; iIndex2++)
              {
                  CBaseElement* pNode2 = g_pElementList[iIndex2];
                  if (pNode2-&gt;GetType() == ET_TOOLTIP || pNode2-&gt;GetType() == ET_CURSOR)
                  {
                      g_pElementList.erase(g_pElementList.begin() + iIndex2);
                      g_pElementList.push_back(pNode2);
                      break;
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>I need a better way of doing this.</p>