[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: QMouseEvent button/state
From:       "Aaron J. Seigo" <aseigo () olympusproject ! org>
Date:       2002-06-30 23:54:14
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 30 June 2002 05:33, John Firebaugh wrote:
> On Sunday 30 June 2002 4:19, Gioele Barabucci wrote:
> > On Sunday 30 June 2002 22:45, John Firebaugh wrote:
> > > How about this:
> > >
> > > // prevent LMB down -> RMB down -> LMB up sequence
> > > if( e->button() == RightButton && e->state() == NoButton )
> > >     emit showMenu( e->globalPos(), deskNum );
> > > else
> > >     QButton::mousePressEvent( e );
> >
> > This is wrong, QButton:: get called if button() = RightButton and state()
> > = LeftButton.
>
> What's wrong with that?

probably nothing, but it also won't show the context menu if any of the 
keyboard modifiers (alt, ctrl, meta, shift) are pressed when RMB'ing

state() includes keyboard modifiers ..

in fact, this is a bug in the current code as well... (try it!) but this 
works:

Index: pagerapplet.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/applets/minipager/pagerapplet.cpp,v
retrieving revision 1.76
diff -u -3 -d -p -r1.76 pagerapplet.cpp
- --- pagerapplet.cpp     2002/06/27 18:51:46     1.76
+++ pagerapplet.cpp     2002/06/30 23:53:52
@@ -156,10 +156,18 @@ void KMiniPagerButton::paintEvent(QPaint

 void KMiniPagerButton::mousePressEvent( QMouseEvent * e)
 {
- -    if ( e->button() != RightButton )
- -       QButton::mousePressEvent( e );
- -    else if (e->state() != LeftButton )
- -       emit showMenu( e->globalPos(), deskNum );
+    if ( e->button() == RightButton &&
+        ! (e->state() & LeftButton ) )
+    {
+        // don't show the menu if the left mouse button is down
+        // since that can result in multiple desktops appearing
+        // to be selected, which is obviously wrong
+       emit showMenu( e->globalPos(), deskNum );
+    }
+    else
+    {
+        QButton::mousePressEvent( e );
+    }
 }


- -- 
Aaron J. Seigo
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

"Everything should be made as simple as possible, but not simpler"
    - Albert Einstein
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9H5om1rcusafx20MRAm/eAJsEl0++QwIeQzULdIfb5NP+DY37vwCfayvU
T+0p3Vy0fE2wsSnRhCJZ1G0=
=gnBZ
-----END PGP SIGNATURE-----

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic