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
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.

How to change button height??

Purpose:

Make a square button on Cascades project or C++.

 

Problem:

Whenever a button preferredHeight is changed, button height does not be changed on the BB10 beta 3 simulator.

 

Code:

Button {
id: record
imageSource: "asset:///img/Record-Normal-80x80-1.png"
preferredWidth: (DisplayInfo.width) * 0.2
preferredHeight: (DisplayInfo.width) * 0.2
}

 

Does anyone know how to make a square button on qml or C++??

 

Thanks your attention.

 

-Fight with BB10
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: How to change button height??

As far as I know it is impossible.

Regular Contributor
Q-T
Posts: 94
Registered: ‎12-02-2011
My Device: non-Blackberry user

Re: How to change button height??

[ Edited ]

I thought you might be able to make your own primative button like this:

MyButton::MyButton(QString text)
{
    //Image regularImage;
    //        Image downImage; // for touch down;
  regularImage = Image(QUrl("asset:///images/regular.png"));
  downImage = Image(QUrl("asset:///images/press.png"));
  setImage(regularImage);
  connect(this,SIGNAL(onTouch(bb::cascades::TouchEvent  *)),this,SLOT(touchEnterSlot(bb::cascades::TouchEvent *)));
  connect(this,SIGNAL(onTouchExit(TouchExitEvent *)),this,SLOT(touchExitSlot(TouchExitEvent *)));
 setEnabled(true);
 addTouchBehavior
}

void MyButton::touchEnterSlot(bb::cascades::TouchEvent *)
{
        qDebug() << "Touch Enter....";
     setImage(downImage);
}

void MyButton::touchExitSlot(TouchExitEvent *)
{
    qDebug() << "Touch Exit....";
     setImage(regularImage);
}

 

MyButton inherrits frim ImageView.  I use images for your button.  However when you run it you get warning about no such signals for onTouch() and onTouchExit().  yet these are signals available in its parent class VisualNode and listed as one of the signals it inherrits.  So why are not those signals available and usable as shown above. 

 

If we get this answered it could be a solution to your square button

Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: How to change button height??

~Q.T you can simply use the 'touch' signal:

https://developer.blackberry.com/cascades/reference/bb__cascades__visualnode.html#touch

 

//something like this
onTouch(TouchEvent* event)
{
  if(event->isUp())
  {
     //similar to your touchExit
  }
  else if(event->isDown())
  {
     //user touched the screen
  }
}