RE: Disabling the cancel button
"Russell Clarke" <[email protected]> Mon, 2 Dec 2002 16:58:37 -0000
| Newsgroups | gmane.comp.handhelds.zaurus.devel |
|---|---|
| Message-ID | <[email protected]> |
> > the code you quote below is from qwsEventFilter, which is called by > > notify(). Are you sure you have overridden notify() correctly? it's a > > public virtual member, so there should not be a problem. > > My program is in Python, so I have to rely on the Python Qt bindings > to handle this correctly. But I do get lots of events, so it can't be > completely wrong. I also get key press events, but not for the Escape > key. More precisely, when I do press the Escape key, there is no key > press event at all. yes you're right, sorry. my mistake: I took too much notice of the documentation :) qwsEventFilter is called directly from processNextEvent, which means there's nothing you can do to un-hack the Cancel key. Here's what you can do (it's not pretty, but it should work): when the close event arises from the cancel key, QApplication::notify() is called by QWidget::close() which is called directly by QPEApplication::qwsEventFilter(). when the event arises from tapping the close button, QApplication::notify() calls QWSManager::event() (this is the mouse event), which (eventually) calls QWidget::close(), which calls QApplication::notify() again (the close event this time). SO: in your derived application class, define a boolean member ReallyClose. in your reimplementation of QApplication::notify(), test for a mouse release event, and set ReallyClose if this is true. then test for a close event, and ignore it if ReallyClose is false. otherwise call the base class function. ALSO: remember that this will only allow your app to be closed by tapping the button. Anywhere you call QWidget::close(), you must also set ReallyClose. hope that works! -- Russell Clarke Picsel Technologies Ltd ------------------------------------------------------- This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en