Issue with adding button in code. Am I doing this right?
Hello!
I am trying to add a button to my application manually through code. I thought it would be quite simple, but for some reason I am having some difficulties.
I have added it my screenView class, and initialised it using bitmapped images from the TouchGFX library.
It displays on screen correctly, but does not respond to any touches. I would expect at this point for the image on screen to change when I press it.
I have added other buttons from the designer, that are responding correctly.
Does anyone have any idea what I am doing wrong? Is there something I am not initialising correctly that links the button to TouchGFX engine?
I'm embarrassed to say that this has stumped me for several hours now!
Thank you.
screenView.hpp:
#ifndef SCREENVIEW_HPP
#define SCREENVIEW_HPP
#include <gui_generated/screen_screen/screenViewBase.hpp>
#include <gui/screen_screen/screenPresenter.hpp>
#include <touchgfx/widgets/Button.hpp>
class screenView : public screenViewBase
{
public:
screenView();
virtual ~screenView() {}
virtual void setupScreen();
virtual void tearDownScreen();
touchgfx::Button Button1;
protected:
private:
};
#endif // SCREENVIEW_HPPscreenView.cpp:
#include <gui/screen_screen/screenView.hpp>
#include <BitmapDatabase.hpp>
screenView::screenView()
{
}
void screenView::setupScreen()
{
screenViewBase::setupScreen();
Button1.setXY(0, 0);
Button1.setBitmaps(touchgfx::Bitmap(BITMAP_ROUND_EDGE_SMALL_ID), touchgfx::Bitmap(BITMAP_ROUND_EDGE_SMALL_PRESSED_ID));
add(Button1);
}
void screenView::tearDownScreen()
{
screenViewBase::tearDownScreen();
}