279 views
in GUI Development by
When I update the visibility of an image through a touch input in dialog A and I open a different dialog B, all the visibility values of the images from dialog A go back to their default values when I switch dialogues. How can I maintain these values even when changing dialogues? Thank you.

1 Answer

0 votes
by

Hello,

when you place an image view into a dialog, you create an instance of the class Views::Image and you can set the properties of the image according to your needs. If you place another image view into another dialog, it is a new instance which has nothing to do with the first image.

Thus, you need to store the visibility state in a separate variable or property and forward the current state from one dialog to the other. See also How to exchange data between dialogs.

Does this answer your question?

Best regards,
Manfred.

by

Thank you Manfred. And how can I read the value of this variable and assign it to the visibility of an image?

For further reference, this is how I have coded the slot brick that handles the touch input, but it does not seem to solve my problem because when I switch dialogues the visibility value gets reset:

if ( Touch_BTSlider )
{

  if ( Application::AO_Variables.BTstate == false )
  {
    Application::AO_Variables.BTstate = true;
    ONSliderVisibility = true;
    Image_BT_SliderON.Visible = ONSliderVisibility;
  }

  else
  {
    Application::AO_Variables.BTstate = false;
    ONSliderVisibility = false;
    Image_BT_SliderON.Visible = ONSliderVisibility;
  }

 

by

Great - in your code you already save the desired visibility state within a global state variable. 

In order to provide this value in your other dialog, you can either use this value as an initialization value of the dialog (e.g. IconsVisible) or you read the global value when your dialog is created (e.g. within the Init() constructor) and assign it to the image members of the dialog.

by

Pardon me for my ignorance, Manfred, but how can I "assign it to the image members of the dialog"?

Here is what I have done following your advise about the Init() method:

1. I have overridden (I think) the Init() method by Ctrl+Shift+Dragging it to my dialog window.

2. I have coded the method with the following line:

Image_BT_SliderON.Visible = Application::AO_Variables.BT_SliderON_State;

Am I on the right path? If that is the case, I do not know how to assign this method my the Image_BT_SliderON image.

 

Thank you greatly for your help.

by
Hello, I think you are on the right path :-)

The Init() method of dialog B is called automatically as soon as the dialog B is created. I assume you open (create) dialog B when you close dialog A. Correct?

You can also post a short example - then it will be easier to have a common understanding.

Best regards,
Manfred.
by

Yes, exactly, I open dialog B when I close dialog A.

I will show you some pictures of my project to enlighten you, I am not savvy enough about the terminology and if I try to explain it to you with words I might end up making it more confusing.

This is 'dialog A' (I called it 'Bluetooth', for future references):

As I said, the Init() method is coded with the following line:

Image_BT_SliderON.Visible = Application::AO_Variables.BT_SliderON_State;

Application::AO_Variables is the autoobject of my Variables class, where I am storing all the global variables of my project. 'BT_SliderON_State' is one of these global variables, I use it to store whether my 'slider' ('Image_BT_SliderON') is on (true) or off (false).

 

When I touch the slider, the following image is shown:

 

And I want it to stay that way, because as soon as I touch the return arrow or the cross button a different dialog opens up, and when I go back to this dialog, the slider is back to being ON instead of OFF, which is how I left it.

 

The way I change dialogs by touching the screen is by coding a slot brick and assigning it to the touch handler. This is the code snippet I use for said slot:

if ( Touch_CrossBT )
{
  SwitchToDialog( new Application::Buttons, null, null, null, null, null, null, null, null, null, false );
}

 

Thank you very much for your help Manfred, I really appreciate it.

by
Have you tried to implement the Init() method within the dialog B? I assume this is missing.

If you still have some issues, please upload the project so that we have a common view.

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

...