Skip to main content

Scroll Wheel

The Scroll Wheel is a scrollable menu containing multiple items, which are dynamically updated when scrolling through the items in the wheel, and the item which is selected is moved into focus. Enabling the code to react to interactions with the Scroll Wheel, different callbacks can be invoked based on the interaction with the items in the wheel.

Scroll Wheel running in the simulator

Widget Group

The Scroll Wheel can be found in the Containers widget group in TouchGFX Designer.

Scroll Wheel in TouchGFX Designer


The properties for a Scroll Wheel in TouchGFX Designer.

Property GroupProperty Descriptions
NameName of the widget. Name is the unique identifier used in TouchGFX Designer and code.
TypeType specifies whether the Scroll Wheel is oriented vertically or horizontally.
LocationX and Y specify the top left corner of the widget relative to its parent.

W and H specify the width and height of the widget.

Lock specifies if the widget should be locked in its current X, Y, W and H.
Locking the widget also disables interacting with the widget through the screen.

Visible specifies the visibility of the widget.
Making the widget invisible also disables interacting with the widget through the screen.
Item TemplateItem Template specifies which CustomContainer to use as template.

Number of Items specifies the number of items present in the Scroll Wheel.

Initial Selected Item specifies which item is selected first.

Use Selected Style Template specifies whether to use a separate template for the selected item.

Selected Style Template specifies which CustomContainer to use as selected template.
List AppearanceCircular specifies if the items in the Scroll Wheel will loop when reaching the end.

Selected Item Offset specifies the location of the selected item.

Item Margin specifies the spacing between items.

Extra Size Before and Extra Size After specify the size of the area in which Selected Style Template is shown.

Margin Before and Margin After specify the size of the margin before and after the area in which Selected Style Template is shown.
AnimationEasing and Easing Option specify which easing equation to use for animations.

Swipe Acc. and Drag Acc. specify the acceleration when scrolling.
MixinsDraggable specifies if the widget is draggable at runtime.

ClickListener specifies if the widget emits a callback when clicked.

MoveAnimator specifies if the widget can animate changes to X and Y values.

Item Templates

The items in a Scroll List are based on a concept called Item Template which is a CustomContainer that serves as a base for the graphical elements for the items in the Scroll Wheel. To highlight the selected item, the Scroll Wheel has the option to select an Item Template called Selected Style Template, which is only used for the selected item. Before creating a Scroll Wheel, a CustomContainer for the Item Template, along with a Selected Style Template if enabled, should be created.

After the Scroll Wheel is created, the CustomContainer can be selected under the property Item Template. When selecting the Custom Container for the Item Template, the Scroll Wheel resizes to fit with the size property that is not in the scrollable direction (width for vertical orientation and height for horizontal orientation) of the selected Custom Container. Changing the other size property (height for vertical orientation and width for horizontal orientation) determines the number of items visible.


The actions and triggers supported by the Scroll Wheel are described in the following sections.


Standard widget actionDescription
Hide widgetHides a widget (sets visibility to false).
Show widgetMake a hidden widget visible (sets visibility to true).


A Scroll Wheel does not emit any triggers.


A Scroll Wheel is a Container type, and does not per default appear in the draw chain. Therefore, the performance is wholly dependent on the drawing performance of the children.

For more details on drawing performance, read the General UI Component Performance section.


Generated Code

In the generated code for the View base class we can see how TouchGFX Designer sets up a Scroll Wheel.

#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include "BitmapDatabase.hpp"

Screen1ViewBase::Screen1ViewBase() :
updateItemCallback(this, &Screen1ViewBase::updateItemCallbackHandler)
scrollWheel.setPosition(140, 10, 200, 252);
scrollWheel.setSelectedItemExtraSize(0, 0);
scrollWheel.setSelectedItemMargin(0, 0);
scrollWheel.setDrawableSize(50, 3);
scrollWheel.setDrawables(scrollWheelListItems, updateItemCallback,
scrollWheelSelectedListItems, updateItemCallback);
scrollWheel.animateToItem(0, 0);


void Screen1ViewBase::setupScreen()
for (int i = 0; i < scrollWheelListItems.getNumberOfDrawables(); i++)
for (int i = 0; i < scrollWheelSelectedListItems.getNumberOfDrawables(); i++)

void Screen1ViewBase::updateItemCallbackHandler(touchgfx::DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex)
if (items == &scrollWheelListItems)
touchgfx::Drawable* d = items->getDrawable(containerIndex);
TextContainer* cc = (TextContainer*)d;
scrollWheelUpdateItem(*cc, itemIndex);
else if (items == &scrollWheelSelectedListItems)
touchgfx::Drawable* d = items->getDrawable(containerIndex);
TextCenterContainer* cc = (TextCenterContainer*)d;
scrollWheelUpdateCenterItem(*cc, itemIndex);
You can use these functions and the others available in the ScrollWheel class in user code. Remember to force a redraw by calling scrollWheel.invalidate() if you change the appearance of the widget.

User Code

After the graphical elements for the Scroll Wheel and its properties are set, user code can be written to update the items in the Scroll Wheel. The header file for the Screen1ViewBase class which is generated by the TouchGFX Designer is shown below:

class Screen1ViewBase : public touchgfx::View
virtual ~Screen1ViewBase() {}
virtual void setupScreen();

virtual void scrollWheel1UpdateItem(CustomContainer1& item, int16_t itemIndex)
// Override and implement this function in Screen1

virtual void scrollWheel1UpdateCenterItem(CustomContainer2& item, int16_t itemIndex)
// Override and implement this function in Screen1

FrontendApplication& application() {
return *static_cast<FrontendApplication*>(Application::getInstance());

touchgfx::BoxWithBorder boxWithBorder1;
touchgfx::ScrollWheelWithSelectionStyle scrollWheel1;
touchgfx::DrawableListItems<CustomContainer1, 6> scrollWheel1ListItems;
touchgfx::DrawableListItems<CustomContainer2, 2> scrollWheel1SelectedListItems;

void updateItemCallbackHandler(DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex);
touchgfx::Callback<Screen1ViewBase, DrawableListItemsInterface*, int16_t, int16_t> updateItemCallback;


When the TouchGFX Designer generates the code for Scroll Wheel, the functions scrollWheel1UpdateItem and scrollWheel1UpdateCenterItem, highlighted above, is created for the user to override and update the items in the Scroll Wheel.

The UpdateItem function is always generated for a Scroll Wheel and can be implemented to updated the contained items, while the UpdateCenterItem function updates the item based on the Selected Style Template and is therefore only generated if the usage of a Selected Style Template is selected. Other than updating different items, the two functions contain the same parameters used for updating the items in the the Scroll Wheel.

The parameter itemIndex contains the index value of the item, which is used to identify which item is being updated. The parameter item is a reference to a visible item in the Scroll Wheel. Updating the appearance for the parameter item results in an update to the render for a visible item in the Scroll Wheel.

An example implementation of scrollWheel1UpdateItem and scrollWheel1UpdateCenterItem in the user code files Screen1View.hpp and Screen1View.cpp is shown below:


#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include <gui/screen1_screen/Screen1Presenter.hpp>

class Screen1View : public Screen1ViewBase
virtual~Screen1View() {}
virtual void setupScreen();
virtual void tearDownScreen();

virtual void scrollWheel1UpdateItem(CustomContainer1& item, int16_t itemIndex);
virtual void scrollWheel1UpdateCenterItem(CustomContainer2& item, int16_t itemIndex);

#endif // SCREEN1_VIEW_HPP
#include <gui/screen1_screen/Screen1View.hpp>



void Screen1View::setupScreen()

void Screen1View::tearDownScreen()

void Screen1View::scrollWheel1UpdateItem(CustomContainer1& item, int16_t itemIndex)

void Screen1View::scrollWheel1UpdateCenterItem(CustomContainer2& item, int16_t itemIndex)

In the header file Screen1View.hpp, the scrollWheel1UpdateItem and scrollWheel1UpdateCenterItem functions are overridden and are then implemented in Screen1View.cpp.

The goal of this example is to update the text in the Item Template with the index value of the items which are visible, like the example shown in the beginning of this section. Since both the Item Template and the Selected Style Template are based on CustomContainer, a setIndex function is created for both CustomContainers. The setIndex function is able to take the itemIndex parameter and update the text in the Item Template and the Selected Style Template. Calling the setIndex for an item results in an update to the appearance of the visible items thereby showing their index value.

TouchGFX Designer Examples

To further explore the Scroll Wheel, try creating a new application within TouchGFX Designer with one of the following UI templates:

Scroll Wheel and List Example UI Template in TouchGFX Designer

API Reference