언어 설정

Menu
Sites
Language
Failed Construct() Button method

Hi, folks! Could anyone help with Button construction problem?

I'm getting the following log message after Construct() call of Button and application crashed:

result Tizen::Graphics::_Text::TextObject::SetBounds(const Tizen::Graphics::FloatRectangle&)(1134) > [E_OUT_OF_RANGE] The given rectangle(width:-4.000000,height:12.000000) is out of range.

In the following code:

MainSimpleButton::MainSimpleButton()
{
	result res = Construct(FloatRectangle(50, 50, 20, 20), String("Default button"));
	if (res != E_SUCCESS)
	{
		throw Exception("Failed Construct() button");
	}
}

 

Here is details. I have customized Button class:

#ifndef MAINBUTTON_H_
#define MAINBUTTON_H_

#include <FApp.h>
#include <FUi.h>
#include <FGraphics.h>

class MainSimpleButton : public Tizen::Ui::Controls::Button {
public:
    MainSimpleButton(); // <------- This constructor is used
    MainSimpleButton(const Tizen::Graphics::Rectangle &rect, const Tizen::Base::String &text);
    MainSimpleButton(const Tizen::Graphics::FloatRectangle &rect, const Tizen::Base::String &text);
    virtual ~MainSimpleButton();
};

#endif /* MAINBUTTON_H_ */

With the following simple implementation:

MainSimpleButton::MainSimpleButton()
{
	result res = Construct(FloatRectangle(50, 50, 20, 20), String("Default button"));
	if (res != E_SUCCESS)
	{
		throw Exception("Failed Construct() button");
	}
}

MainSimpleButton::MainSimpleButton(const Rectangle &rect, const String &text)
{ // Similar to MainSimpleButton }

MainSimpleButton::MainSimpleButton(const FloatRectangle &rect, const String &text)
{ // Similar to MainSimpleButton }

MainSimpleButton::~MainSimpleButton() {}

Add instance of this customized Button() is created here:

void MainForm::InitMainForm(unsigned long formStyle)
{
    if (Construct(formStyle) != E_SUCCESS) { throw Exception("MainForm Construct() failed"); }
	MainSimpleButton *btn1 = new MainSimpleButton(); // <----- This code
	if (AddControl(btn1) != E_SUCCESS)
	{
		throw Exception("MainForm AddControl() failed");
	}
}

 

Responses

4 댓글
Victor Malov

Not sure is this correct answer, but here is the link: StackOverflow question. Could anyone confirm that I'm right and this approach is not working well with Tizen framework?

It is recomended to use two-phase construction method with Tizen.

Create new public method (Init() for example) and then place the Construct code inside it and try again

MainSimpleButton *btn1 = new MainSimpleButton();
btn1->Init();

 

 

 

Victor Malov

Thanks. Now my approach (with constructors) is working, after cleaning and refactoring all code.

But in any case Tizen should support this one as smoothly as their original, with Construct(), method because

finally we get the same correct call chains of functions.

Alex Dem

Hi, just fyi.
you could add button on form like it is described here(usually it is enough):
https://developer.tizen.org/dev-guide/2.2.1/org.tizen.native.apireference/classTizen_1_1Ui_1_1Controls_1_1Button.html
Alexey.