467 views
in GUI Development by
In many cases the number of items within a list or menu may change during runtime. What is the best possibility to manage a variable number of menu items or scroll-list items?

1 Answer

0 votes
by
Within a scroll list (classes Core::HorizontalList and Core::VerticalList) the number of items is limited to 2^31. To change the number of items dynamically, simply assign a new value to the list's property 'NoOfItems'. Please note, that the scroll list classes does not store all the items intended to be shown in the list. Instead of this, the list asks for the items to show as soon as the user scrolls the item into the visible area. See the list's property 'OnLoadItem'. Usually you should implement a slot method and assign it to this 'OnLoadItem' property. Then the slot method is called automatically by the list when a new item needs to be loaded into the list.

The case of menus eventually expects additional explanation. You can of course implement the menu by using the scroll lists mentioned above.

However, the scroll lists are intended more to show items of the same kind. Assuming you intend to implement a menu consisting of very, very different components, so it would be more convenient to take these components and arrange them within a group (class Core::Group). This can be done as well at the design-time in the Embedded Wizard composer or the components can be created and added to the group dynamically at the runtime.

The group class provides several methods you can use to navigate between the components (e.g. the 'Find' methods (e.g. 'FindAtPosition') and the property 'Focus', etc.), so the usual menu can be created in a very simple manner. Additionally, the class Core::Outline allows you to arrange, scroll and clip components of a group automatically. So complex panels, dialogs or even menus can be designed without or with few lines of code. In the gallery folder 'Panel Templates' we provide a template of a menu based on a group where an outline object is used to scroll and clip the menu's items. To use the template drag it from the gallery into composer. However you should ensure first that a unit is opened currently in the composer otherwise the drag operation is declined. So created menu class can then be opened, investigated and modified accordingly to your needs. (It is even a template).

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...