[Panel-devel] mousePressEvent() and contentRect()

Jason Stubbs jasonbstubbs at gmail.com
Fri Dec 21 16:21:30 CET 2007


Hi all,

I've gone through and fixed where I've found the issue, but I'll go over it 
here so that it hopefully doesn't happen again. ;)

When overridding mousePressEvent for a Plasma::Applet, you pretty much always 
want to ignore it if its not within contentRect(). The reason for this is 
that, unlike QWidgets, you will get clicks for the frame as well.

Ordinarily you'll want to ignore these so that the applethandle (or whatever 
else) can recieve and do nice things like allowing the user to move the 
applet. Likewise, be sure to ignore() anything that you are not handling, 
unless you specifically don't want it to be handled.

On the flip side, blindly calling Applet::mousePressEvent() is not a good idea 
either. Calling it in place of ignore() just in case Applet some day 
overrides it is fine, but blindly calling it means that you are ignoring all 
events unless you accept() after the call. This translates to a click event 
being handled by your applet *and* moving of the applet being started.

I've fixed the contentRect() issues in the four clocks and the comic applet, 
but haven't touched anything that is calling Applet's mousePressEvent because 
I couldn't tell from a glance what was intended.

-- 
Jason Stubbs


More information about the Panel-devel mailing list