141 views
in GUI Development by
Hi,

In menu screen there is a vertical list with items, I am selecting an item (3rd or 4th) option in one class, if am going out of the screen, while coming back to the menu screen. the item I selected previously should be highlighted rather than the first item.

Is there any method or property available for above case.

 

Thanks,
Harshini

1 Answer

0 votes
by

Hello Harshini,

I suppose that with "coming back to the menu screen" you present a new instance of the menu. Consequently, the new instance has no information about the selection you made in the preceding instance. Here we see two possible approaches:

Approach 1: Reuse the same instance of the menu. This would mean that the instance is not created using the new operator each time it is presented. Instead you maintain one instance for example in a variable existing in your Application component and you use this instance when the menu should be presented. 

The disadvantage of this approach is, the menu occupies RAM the whole time. This may be even few kB RAM depending on the menu content. The usage of this approach depends thus on the resources of your target.

Approach 2: Store the selection information (the number of the recently selected item) in a variable outside the menu. Next time, when the menu is presented again, read the variable and use it to restore the previous selection situation. In the simplest case, you would need to store the content of the property Vertical List property SelectedItem. To manage a variable outside the menu you could use an autoobject. It is a kind of global object which allow you store global data. In your application case it could be sufficient to manage in the class of the autoobject just one int32 variable.

You could store the content of the property SelectedItem in a variable existing in the autoobject each time the user changes the selection in the menu. Later when the menu is presented again, you read the variable from the autoobject and use it to restore the property SelectedItem. Depending on the design of your menu, you could implement this in the Init() method of the Menu component or in the UpdateViewState() method.

This approach requires more coding. On the other hand it is more flexible. You could even store the content of the autoobject in a flash memory so the menu selection can be restored even after the device has been switched off in the meantime.

Important: If you are using autoobjects, please note that they are automatically discarded if not used anymore. Therefore, if the autoobject is used from the Menu only, you will need to store a reference to the autoobject within a variable existing in Application component. See also the section Lifetime of an autoobject.

I hope it helps you further.

Best regards

Paul Banach

by

Hi paul,

I tried with your approach , but I haven't got result as expected. am unable to get the same previous screen when am coming back 

I am having another doubt related to this, 

Currently in our implementation we are not using present dialogue for switching screens instead of this we are using new instance with switch to dialogue.

2. when am switching from lower menu to upper menu (1 screen to other screen) I need to store 3 details of present menu

  • selected item
  • first available item which is visible on the screen inside vertical list. (No of items visible ; 4) Note: total no of items : 8
  • Last available item which is visible on the screen inside vertical list.(No of items visible ; 4)
on a simple way if I want to conclude it means when am coming back from present to previous screen I need to recreate the previous screen item data in vertical list  
whatever logic if we need to implement that has to work for all 50 screens
 
is it possible to store above 3 details  before switching screens and need to retrieve after coming back to the previous screen ?
by

Hello Harshini,

without knowing your implementation it is difficult to give you a concrete advise. From your description I understood you recreate the dialogs each time the user navigates forth and back. In such case I would manage a global autoobject where the dialogs store/load their settings.

Well, I'm not sure whether it answers your question.

Best regards

Paul Banach

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

...