In this step of tutorial 4, we will create a Scroll Wheel by using the
Custom Container, "MenuElement", created in step 1. As described in step 1, the
Scroll Wheel is used to create a scrollable menu containing multiple selectable items. The items in the wheel are dynamically updated when scrolling and when selecting an item, it is moved into focus.
Adding items to the
Scroll Wheel is done by selecting a
Custom Container to use as an "Item Template". The concept of "Item Template" works by using the widgets in the Custom Container as the foundation for the items in the Scroll Wheel and use user code to update the widgets in the items at runtime.
Creating the Scroll Wheel
Before creating the Scroll Wheel, remove the
Custom Containers on the screen, leaving only is the black box as the background. Select the
Scroll Wheel located in the widgets tab under section Containers. Create a
Scroll Wheel and set the location properties to X = 208, Y = 45 and H = 390 and change the name to "scrollWheel".
Adding Items to the Scroll Wheel
Select "MenuElement" created in step 1 as the "Item Template", which is done with the drop-down list under the
Scroll Wheel property "Item Template". The number of items in the
Scroll Wheel is also set under "Item Template", which we are going to set to 20. Since the
Scroll Wheel works by having a selected item in focus, setting where the selected item is positioned, is done by setting "Selected Item Offset" under the property "List Apperance". We want the selected item to be in the middle of the
Scroll Wheel and are therefore setting "Selected Item Offset" to 160.
To highlight area the of "scrollWheel", the two pictures background.png, and overlay.png from the .zip file downloaded in step 1 are used and is added to the application as image widgets. The two images is a background that highlights the area of "scrollWheel" and an overlay which hides the items in "scrollWheel" when the are moved to the edge of "scrollWheel".
The image background.png are placed in X = 205 and Y = 45 and is placed behind "scrollWheel" so the items in "scrollWheel" is drawn op top of the background. The overlay.png is placed in X = 0 and Y = 0 on top of "scrollWheel" meaning that the items are drawn beneath overlay.png thereby hiding the items where overlay.png is not transparent.
Since we only have adjusted the static properties for "scrollWheel", logic has not been added to it. Running the application will, therefore, result in a scrollable menu consisting of 20 items that all show the same. In the next step, we will add the logic to the "scrollWheel" with user code which updates the items in the wheel at runtime.