cancel
Showing results for 
Search instead for 
Did you mean: 

scrollWheel index incorrect, not responsive

FJB2069
Senior

I want to create a scrollWheel that has 3 preset options.  Option A, Option B,  and Option A&B

The issue I have is that I can never get itemIndex  = 1 in scrollWheelUpdateItem callback , only index 0 and 2.  Also, after I first change wheel, it takes a while to be able to change it again.

I tried to provide all the relevant code and touchgfx setup.  

Appreciate if you can tell me what is incorrect.

 

Here is my Container  (MenuItem):

FJB2069_1-1737391403340.png

Here is how I set up my text:

FJB2069_0-1737391266784.png

scrollWheel:

FJB2069_2-1737391503713.png

 

Here is Container MenuItem.cpp:

#include <gui/containers/MenuItem.hpp>
#include <texts/TextKeysAndLanguages.hpp>
#include <BitmapDatabase.hpp>


MenuItem::MenuItem()
{

}

void MenuItem::initialize()
{
    MenuItemBase::initialize();
}

void MenuItem::setWheelElements(int item)
{
	switch (item)
	{
	case 0:
		text.invalidate();
		text.setTypedText(TypedText(T_S1));
		break;
	case 1:
		text.invalidate();
			text.setTypedText(TypedText(T_S2));
			break;
	case 2:
		text.invalidate();
			text.setTypedText(TypedText(T_S3));
			break;

	}

}

MenuItem.hpp:

#ifndef MENUITEM_HPP
#define MENUITEM_HPP

#include <gui_generated/containers/MenuItemBase.hpp>

class MenuItem : public MenuItemBase
{
public:
    MenuItem();
    virtual ~MenuItem() {}

    virtual void initialize();
    void setWheelElements(int item);
protected:
};

#endif // MENUITEM_HPP

Buttons1MenuView.cpp

#include <gui/buttons1menu_screen/Buttons1MenuView.hpp>
#include <gui_generated/common/FrontendApplicationBase.hpp>
#include "config_file.h"
#include "math.h"


Buttons1MenuView::Buttons1MenuView()
{

}

void Buttons1MenuView::setupScreen()
{
    Buttons1MenuViewBase::setupScreen();

    
}

void Buttons1MenuView::tearDownScreen()
{
    Buttons1MenuViewBase::tearDownScreen();
}


void Buttons1MenuView::scrollWheelUpdateItem(MenuItem& item, int16_t itemIndex)
   {
	scrollWheel.invalidate();  //NOT SURE IF NEEDED
   	item.setWheelElements(itemIndex);

   }

Buttons1MenuView.hpp

#ifndef BUTTONS1MENUVIEW_HPP
#define BUTTONS1MENUVIEW_HPP

#include <gui_generated/buttons1menu_screen/Buttons1MenuViewBase.hpp>
#include <gui/buttons1menu_screen/Buttons1MenuPresenter.hpp>

class Buttons1MenuView : public Buttons1MenuViewBase
{
public:
    Buttons1MenuView();
    virtual ~Buttons1MenuView() {}
    virtual void setupScreen();
    virtual void tearDownScreen();
   
    virtual void scrollWheelUpdateItem(MenuItem& item, int16_t itemIndex);





protected:
};

#endif // BUTTONS1MENUVIEW_HPP

 

 

 

 

 

1 REPLY 1
FJB2069
Senior

I increased the size of the scrollWheel window (still making it only show one item) it responds much better and I do now get valid itemIndex, accept the index number does agree to what I thought it should be.

FJB2069_1-1737395078839.png

In other words,  I assume Option A should have index 0,  Option B index 1 and Option AB index 2,

but I get Option A index 1, Option B index 2 and Option AB index 0

Anyone know why the indexes as not as expected?