From 1a24a61265d498ab3948c79c99efdc53f576dc61 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Tue, 15 Sep 2009 19:09:22 +0000 Subject: fixed button focus behavior (patch by erlk.ozlr AT gmail.com) git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1224 90c681e8-e032-0410-971d-27865f9a5e38 --- src/ui/button.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/ui/button.cpp') diff --git a/src/ui/button.cpp b/src/ui/button.cpp index b9ee9cf09..4ec67ac4d 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -23,6 +23,7 @@ #include "button.h" #include "skin.h" +#include Button::Button (QWidget *parent, uint normal, uint pressed) : PixmapWidget (parent) @@ -53,11 +54,24 @@ void Button::setON (bool on) void Button::mousePressEvent (QMouseEvent *e) { setON (TRUE); + m_cursorin = TRUE; QWidget::mousePressEvent(e); } void Button::mouseReleaseEvent (QMouseEvent*) { setON (FALSE); - emit clicked(); + if (m_cursorin) + emit clicked(); +} + +void Button::mouseMoveEvent (QMouseEvent *e) +{ + if ( !m_cursorin && rect().contains(e->pos()) ) { + m_cursorin = TRUE; + setON (TRUE); + } else if ( m_cursorin && !rect().contains(e->pos()) ) { + m_cursorin = FALSE; + setON (FALSE); + } } -- cgit v1.2.3-13-gbd6f