summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugingui/button.cc16
-rw-r--r--plugingui/button.h3
-rw-r--r--plugingui/eventhandler.cc9
-rw-r--r--plugingui/widget.h3
4 files changed, 31 insertions, 0 deletions
diff --git a/plugingui/button.cc b/plugingui/button.cc
index 05d16a2..2370f29 100644
--- a/plugingui/button.cc
+++ b/plugingui/button.cc
@@ -29,6 +29,7 @@
#include "painter.h"
#include <stdio.h>
+#include <hugin.hpp>
GUI::Button::Button(Widget *parent)
: GUI::Widget(parent)
@@ -110,6 +111,21 @@ void GUI::Button::setText(std::string text)
repaintEvent(NULL);
}
+void GUI::Button::mouseLeaveEvent()
+{
+ DEBUG(button, "Leave\n");
+ if(state == down) {
+ state = up;
+ repaintEvent(NULL);
+ }
+}
+
+void GUI::Button::mouseEnterEvent()
+{
+ DEBUG(button, "Enter\n");
+}
+
+
#ifdef TEST_BUTTON
//Additional dependency files
//deps:
diff --git a/plugingui/button.h b/plugingui/button.h
index f39f24f..89cabf5 100644
--- a/plugingui/button.h
+++ b/plugingui/button.h
@@ -50,6 +50,9 @@ public:
virtual void repaintEvent(RepaintEvent *e);
virtual void buttonEvent(ButtonEvent *e);
+ virtual void mouseLeaveEvent();
+ virtual void mouseEnterEvent();
+
private:
Painter::Box box_up;
Painter::Box box_down;
diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc
index 1cf67fc..050c2e1 100644
--- a/plugingui/eventhandler.cc
+++ b/plugingui/eventhandler.cc
@@ -447,6 +447,15 @@ void GUI::EventHandler::processEvents(Window *window)
MouseMoveEvent *me = (MouseMoveEvent*)event;
Widget *w = window->find(me->x, me->y);
+ Widget *oldw = window->mouseFocus();
+ if(w != oldw) {
+ // Send focus leave to oldw
+ if(oldw) oldw->mouseLeaveEvent();
+ // Send focus enter to w
+ if(w) w->mouseEnterEvent();
+
+ window->setMouseFocus(w);
+ }
if(window->buttonDownFocus()) {
Widget *w = window->buttonDownFocus();
diff --git a/plugingui/widget.h b/plugingui/widget.h
index 34cdaee..47c374e 100644
--- a/plugingui/widget.h
+++ b/plugingui/widget.h
@@ -66,6 +66,9 @@ public:
virtual void scrollEvent(ScrollEvent *e) {}
virtual void keyEvent(KeyEvent *e) {}
+ virtual void mouseLeaveEvent() {}
+ virtual void mouseEnterEvent() {}
+
Widget *find(size_t x, size_t y);
virtual Window *window();