2025-01-19 05:05 PM
I cannot get scrollWheelUpdateItem callback to fire when the scrollWheel is moved.
void Button1MenuView::scrollWheelUpdateItem(MenuElement& item, int16_t itemIndex)
{
// Override and implement this function in Button1Menu
item.setNumber(itemIndex);
}
scrollWheelUpdateItem only gets called once in Button1MenuView.cpp prior to setupScreen:
void Button1MenuView::setupScreen()
{
Button1MenuViewBase::setupScreen();
for (int i = 0; i < scrollWheelListItems.getNumberOfDrawables(); i++)
{
scrollWheel.itemChanged(i);
scrollWheelListItems[i].updateText(i);
}
}
I assume it should get called whenever the scroll wheel is touched? Or do I
need to set up a different callback?
My Container for scrollWheel is MenuElement.cpp:
#include <gui/containers/MenuElement.hpp>
#include <texts/TextKeysAndLanguages.hpp>
MenuElement::MenuElement()
{
}
void MenuElement::initialize()
{
MenuElementBase::initialize();
}
void MenuElement::updateText(int16_t value)
{
Unicode::snprintf(textBuffer, TEXT_SIZE, "%s", touchgfx::TypedText(TEXTS(value)).getText()); //Find the correct TEXT_ID based on is position in the TEXTS enum.
text.invalidate();
}
MenuElement.hpp
#ifndef MENUELEMENT_HPP
#define MENUELEMENT_HPP
#include <gui_generated/containers/MenuElementBase.hpp>
#include <images/BitmapDatabase.hpp>
class MenuElement : public MenuElementBase
{
public:
MenuElement();
virtual ~MenuElement() {}
void updateText(int16_t value);
virtual void initialize();
void setNumber(int no)
{
Unicode::itoa(no, textBuffer, TEXT_SIZE, 10);
switch (no % 7)
{
case 0:
icon.setBitmap(Bitmap(BITMAP_ICON00_ID));
break;
case 1:
icon.setBitmap(Bitmap(BITMAP_ICON01_ID));
break;
case 2:
icon.setBitmap(Bitmap(BITMAP_ICON02_ID));
break;
case 3:
icon.setBitmap(Bitmap(BITMAP_ICON03_ID));
break;
case 4:
icon.setBitmap(Bitmap(BITMAP_ICON04_ID));
break;
case 5:
icon.setBitmap(Bitmap(BITMAP_ICON05_ID));
break;
case 6:
icon.setBitmap(Bitmap(BITMAP_ICON06_ID));
break;
}
}
protected:
};
#endif // MENUELEMENT_HPP
Solved! Go to Solution.
2025-01-19 05:59 PM
I figured it out. I had a 3 item wheel and all three were being shown. I made the scrollWheel smaller so only one item is shown, so now when I scroll the wheel to the next item it triggers.
2025-01-19 05:59 PM
I figured it out. I had a 3 item wheel and all three were being shown. I made the scrollWheel smaller so only one item is shown, so now when I scroll the wheel to the next item it triggers.