[Kde-games-devel] KGamePopupItem issues
Parker Coates
parker.coates at gmail.com
Tue Nov 25 00:41:38 CET 2008
Hello folks and Dmitry in particular,
I just spent a bit of time cleaning up my use of KGamePopupItem in
Killbots. I had noticed that clicking on a popup in Killbots no
longer hid it and in the course of trying to fix this, I noticed a
couple problems.
Of course I started from the assumption that the problem lie with my
own code. I spent quite a bit of time adding kDebug() calls to my
scene's mouse event handlers, before abandoning that approach. I
started looking at the KGamePopupItem code and noticed a "new"
m_hideOnClick parameter. Looking at the API, I discovered that a "new"
getter and setter for that parameter were added, but the default was
false. I added a setHideOnMouseClick(true) call and the hiding
started working again.
Is it not protocol to leave the default behaviour intact when making a
change like this? I know an email was sent to the list, but I had read
it and dismissed it, as I thought it didn't apply to me since Killbots
used the click-to-close behaviour. I also realise the change was made
last April and I just noticed the problem today, so obviously it
didn't have that big an effect.
The other issue I encountered is that sometimes the popup wouldn't
hide when clicked even after I figured out the above. Sometimes it
would close on the first click, sometimes it would take several.
Eventually, I determined that the problem lie with using a child item
to display the text. If the click falls on the embedded text item, the
popup's event handler doesn't get called, so the popup doesn't get
hidden.
I'm not sure how to fix this. The text item has its own mouse event
handlers to properly handle the link functionality, so any attempt to
grab all mouse release events would break the link handling, and as
far as I know, there's no way to grab only the clicks on regular text
the the text item ignores. Does anyone have any idea of how to do this
correctly.
Parker
More information about the kde-games-devel
mailing list