[Kde-games-devel] Re: Connect a button with KGameIO
cantabile
cantabile.03 at wanadoo.fr
Thu Sep 18 12:36:27 CEST 2003
It works, thanks Andreas : I connected the button like that :
KPlayer* pl = boardDoc->getPlayer(boardDoc->mCurrentPlayer);
KGameIO *plio = pl->findRttiIO(playerRTTI);
dynamic_cast<MatchesMouseIO *>(plio)->moveDone();
But thtere is another question, now :
my MatchesMouseIO::moveDone() method calls sendInput(msg) in order to
process the player move. Where do I get back (I mean retrieve, pick up)
the msg now ?
So far, I have a KMatchesDoc::playerInput() method and a
KMatchesView::slotMouseInput() method, but none of them seem to receive
something.
When thinking of it, it seems logical, since the button is not connected
to the mouse methods but to its own clicked() signal. So where is the
msg sent ? I read in the sources it is sent to KGame. Is there another
method than playerInput() in KGame I would have overlooked ?
Thanks.
Le lun 15/09/2003 à 03:03, Andreas Beckermann a écrit :
> On Sunday 14 September 2003 02:57, cantabile wrote:
> > Hi,
> > I'm trying to connect a button (in a toolbar) with a KGameIO method, and
> > I don't succeed at the moment.
> > Since the KGameIO is linked to the player, not to a view or a document
> > object, how can I do it ?
> > My button is created via :
> > KAction * action = new KAction(play,...)
> > My KGameIO method is in an inherited class. We can call it moveDone, as
> > Andreas and Martin suggested before.
> >
> > I tried while constructing the interface
> >
> > connect(play, SIGNAL(clicked()), ***, SLOT(slotPlay()));
> >
> > But the problem is with the ***: KGAmeIO* io doesn't work, of course,
> > since it isn't instanciated.
>
> what about
> connect(play, SIGNAL(clicked()), mLocalPlayerIO, SLOT(slotPlay()));
> assuming mLocalPlayerIO is your KGameIO derived class that has a slot called
> "slotPlay()".
>
> Another solution (I usually prefer that one):
> connect(play, SIGNAL(clicked()), this, SLOT(slotPlay()));
> and
> MyWidget::slotPlay()
> {
> mLocalPlayerIO->doSomthing();
> }
>
> > I tried also to connect the method in the KGamIO constructor, but the
> > button (play) isn't recognize (build) yet.
> > I also tried to get the io from the player (in slotPlay() )but didn't
> > find a method with a KGameIO return type.
>
> What about KPlayer::findRttiIO(rttiOfYourKGameIO) ?
> (don't forget to check for NULL in case of errors)
>
> The mLocalPlayerIO above can be replaced by a call to findRttiIO() of course
> (and maybe a cast to the derived class)
>
> > This is certainly a stupid question but I'm stuck there :)
> > Thanks for your help.
>
> CU
> Andi
> _______________________________________________
> kde-games-devel mailing list
> kde-games-devel at mail.kde.org
> http://mail.kde.org/mailman/listinfo/kde-games-devel
More information about the kde-games-devel
mailing list