Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
luisdr22
Posts: 20
Registered: ‎09-02-2013
My Carrier: Claro Codetel

click event on a container

[ Edited ]

hi guys!, i have a class that work as a container, inside has more container, and inside those containers are information and an image.

 

what i want to do is when the full container is click, to do something...
i dont know how to do it on c++..

 

something like this:

 

 connect(this,SIGNAL(clicked()), this, SLOT(onContainerClicked()));


but its not working, because it doesnt have a click method, how should i implement it?

or should i change from container to another class ? (inherit from container "class MyClass: public bb::cascades::Container")

 

Please use plain text.
Developer
BBSJdev
Posts: 4,976
Registered: ‎07-05-2012
My Carrier: Orange

Re: click event on a container

You will have to tie in to the onTouch signal, I suggest you read this first though before ploughing ahead...

 

http://developer.blackberry.com/native/documentation/cascades/dev/touch/touch_propagation.html


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Contributor
luisdr22
Posts: 20
Registered: ‎09-02-2013
My Carrier: Claro Codetel

Re: click event on a container

i saw some examples.. but its not working.. , i read the link too. i choosed Tap... this is my code, in the constructor:

 

 TapHandler *pTapHandler = TapHandler::create()
        .onTapped(this, SLOT(onMyClassClicked(bb::cascades::TapEvent*)));

 

this is the handler:

void MyClass::onMyClassClicked(bb::cascades::TapEvent* tapEvent)
{
	 Q_UNUSED(tapEvent)
	this->setBackground(Color::Blue);
}

 

this its the .h :

 

public slots:
	void onMyClassClicked(bb::cascades::TapEvent* tapEvent);

 i added everything as the example does (CascadeCookBook)

 

this means, in the .h:

 

namespace bb
{
    namespace cascades
    {
        class TapEvent;
    }
}

 

and in the .cpp

 

#include <bb/cascades/TapHandler>

 and lets remember that my class is:

class MyClass: public bb::cascades::Container

 its a container.

 

with this.. my code its getting this error:

 

Object::connect: No such slot bb::cascades::Container::onMyClassClicked(bb::cascades::TapEvent*) in ../src/MyClass.cpp:87
ASSERT: "res" in file C:/bbndk/target_10_2_0_1155/qnx6/usr/include/bb/cascades/core/baseobject.h, line 270

 any help?... it actually build and everything, but when it start , it cloose it self cause the error.

 

 

many thanks, i know im asking stupid questions.. but i would like a lil help so i wont do stupid things anymore :$.

 

Please use plain text.
Contributor
luisdr22
Posts: 20
Registered: ‎09-02-2013
My Carrier: Claro Codetel

Re: click event on a container

still waiting :smileysad:
Please use plain text.
Developer
BBSJdev
Posts: 4,976
Registered: ‎07-05-2012
My Carrier: Orange

Re: click event on a container

[ Edited ]

You're missing the addGestureHandler(pTapHandler).


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Contributor
luisdr22
Posts: 20
Registered: ‎09-02-2013
My Carrier: Claro Codetel

Re: click event on a container

where? im sorry :smileysad: im so noob in this :/

Please use plain text.
Developer
BBSJdev
Posts: 4,976
Registered: ‎07-05-2012
My Carrier: Orange

Re: click event on a container

Just after your TapHandler declaration.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
BBSJdev
Posts: 4,976
Registered: ‎07-05-2012
My Carrier: Orange

Re: click event on a container

Also it's probably not a good idea to subclass from Container.

 

Generally in C++ if you can't see the class code and it's ancestors classes (which you can't in this case) and the documentation is not extensive (which it's not) then it can be dangerous to subclass. Too many things can come back to bite you as you extend the class and start overriding functions, etc..

 

I recommend switching to subclassing CustomControl instead and declaring your container as the root control of that.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.