Hi I was looking for a way to know if a window gained or lost focus and I noticed that this wasn't possible in the vgui now.

So I tried to add this functionality

to do this I had to change 2 files

vgui_event.h
-----------------

Added the 2 vgui_events

this is what the enum looks like now

enum vgui_event_type
{
  vgui_EVENT_NULL = 0,
  vgui_ENTER,
  vgui_LEAVE,
  vgui_BUTTON_DOWN,  /* */ vgui_MOUSE_DOWN = vgui_BUTTON_DOWN, vgui_MOUSE_PRESS = vgui_BUTTON_DOWN,
  vgui_BUTTON_UP,    /* */ vgui_MOUSE_UP = vgui_BUTTON_UP, vgui_MOUSE_RELEASE = vgui_BUTTON_UP,
  vgui_MOTION,       /* */ vgui_MOUSE_MOTION = vgui_MOTION,
  vgui_KEY_PRESS,    /* */ vgui_KEY_DOWN = vgui_KEY_PRESS,
  vgui_KEY_RELEASE,  /* */ vgui_KEY_UP = vgui_KEY_RELEASE,
  vgui_RESHAPE,
  vgui_TIMER,
  vgui_DRAW,
  vgui_DRAW_OVERLAY, /* */ vgui_OVERLAY_DRAW = vgui_DRAW_OVERLAY,
  vgui_STRING,
  vgui_HSCROLL,
  vgui_VSCROLL,
  vgui_DESTROY,
  vgui_IDLE,
  vgui_OTHER,
  vgui_EVENT_MAX,
  vgui_FOCUSGAINED,   //--Added--
  vgui_FOCUSLOST  //--Added--
};


and since I only fixed it for qt at the moment I also changed the vgui_qt_adaptor.h and vgui_qt_adaptor.cxx

vgui_qt_adaptor.h
-------------------------

Added:

protected:
   void windowActivationChange (bool oldActive);

Dropped:

void focusInEvent     (QFocusEvent* e);
void focusOutEvent    (QFocusEvent* e);


vgui_qt_adaptor.cxx
----------------------------

Added:

//--------------------------------------------------------------------------------
void vgui_qt_adaptor::windowActivationChange (bool oldActive)
{
   vgui_event ev;

   if(!oldActive)
    ev.type = vgui_FOCUSGAINED;
   else
    ev.type = vgui_FOCUSLOST;
   dispatch_to_tableau(ev);
}


Dropped:

void vgui_qt_adaptor::focusInEvent     (QFocusEvent* e){}
void vgui_qt_adaptor::focusOutEvent    (QFocusEvent* e){}



I dropped the focusInEvent en focusOutEvent since they don't seem to do their job properly


hope this helps

--
Grtz
Rowin Heymans