378 views
in Embedded Wizard Studio by
Hi Team,

I want to show my data what i have entered in screen 1 to screen 2. What i mean is if i enter a value in the text editor box of screen 1, it should get reflect in screen 2. How can i do that?

Thanks

2 Answers

0 votes
by

Hello rangsons,

just in the moment when you present screen 2, query the value from screen 1 and pass it to screen 2. To query the value you should implement in screen 1 a property representing the value or a method to query the value (see also Implementing component interface). Similarly, in screen 2 implement a property or method to assign a value to it. Using the properties (or methods) you transfer the data between the dialogs. For example:

// Access the screen 1
var Application::Screen1 screen1 = ...

// Create a new instance of screen 2
var Application::Screen2 screen2 = new Application::Screen2;

// Transfer some data from screen 2 to screen 1
screen2.SomeProperty = screen1.SomeProperty;

// Present screen 2
PresentDialog( screen2, ... );

I hope it helps you further.

Best regards

Paul Banach

by
Hi Paul,

Really I am struggling with this data transfer between Dialogs(Screens). Can You Please guide me with the step by step process by including screenshots?

Regards

Rangsons
0 votes
by

Hello,

in case you want to have variables (e.g. to store some settings) that should be accessible from different components within your applications, you can put these variables into a separate class and create an autoobject of this class (e.g. Application::Settings). See also this answer.

Hope this helps...

Manfred.

by
Hi Manfred,

Really I am struggling with this data transfer between Dialogs(Screens). Can You Please guide me with the step by step process by including screenshots?

Regards

Rangsons
by

Hi Rangsons,

please follow the above mentioned link - there you will find a step by step guide to implement that. Hopefully this helps...

Best regards,

Manfred.

by

Hi Manfred,

This is My Unit

I have two Dialogs: Component and Component1

 

 

In Component Dialog, I am typing some data in TextEditor boxes using Virtual Keyboard and I want to show that data in the Component1 Dialog.

 

This is my Component1 Dialog. I want the data what I have entered in the Component Dialog to Component1 Dialog.

Please Look into it and Give me suggestion

Regards

Rangsons

by

Hello Rangsons,

there are so many different application cases, that it makes me difficult to give you a concrete solution for your application. So I can try to only outline the concepts. For more details I recommend you our documentation.

Regardless of your application case, in both dialogs you will need to implement some kind of data interfaces. Through these interfaces you exchange data with the components, e.g. you can query which value is actually stored in the text field Test Name and you can assign new content to display in this text field. Following is the approach how to implement such interface for one value (e.g. Test Name):

Step A.1: In the Application::Component add a new property.

Step A.2: Name the property according to whatever value it should represent. For example, if the property is intended to represent the value corresponding to the Test Name text field, you could name it TestName.

Step A.3: Configure the type property to correspond to whatever the property should be intended to store. For example, if Test Name is a string, then the corresponding property should be configured with data type string.

Step A.4: Edit the OnSet method associated to the property (found as brick just below the property). This method is invoked when new content is assigned to the property and its job is to update the component with the new value. For example, in case of the TestName property, you could relay the assigned value directly to the Test Name text view:

// Relay the just assigned value to the TestNameText view.
TestNameText.String = value;

Step 5: Edit the OnGet method associated to the property (found as brick just below the above described OnSet method). This method is invoked when the content of the property is evaluated (queried) within an expression. For example, in case of the TestName property, you could return the value stored actually in the Test Name text view:

return TestNameText.String;

With the step 1-5 you enhanced the component by an interface composed of one property. Through this interface you can communicate with the component. You can assign a value to display in the component and you can query which value is actually displayed in the component. Since you have more than one value to exchange, repeat the steps 1-5 for all other values (e.g. Prod Name, Prod Type, ...).

Step A.6: Shortly before you present a component as dialog, assign the right values to the corresponding properties. This will have the effect of the assigned values to appear in the dialog. For example:

// Create a new instance of the component.
var Application::Component dialog = new Application::Component;

// Initialize its properties
dialog.TestName = "Some Test Name";
dialog.ProdName = "Some Prod Name";
...

// Present the dialog
PresentDialog( dialog, ... );

Step A.7: When you want the value from one dialog to be passed to other dialog, then you have to clarify the question how does the navigation between the dialogs work. Generally you will access the values found in the first dialog and pass them to the second dialog by using the above described interfaces. For example, if the first dialog implements a button to dismiss the actual dialog and present a second dialog, you could implement following code in the method triggered by the button:

// Create a new instance of the component to present as dialog.
var Application::Component1 dialog = new Application::Component1;

// Initialize the properties of the new dialog with values found in 'this'
// dialog.
dialog.TestName = TestName;
dialog.ProdName = ProdName;
...

// Switch to the new dialog
Owner.SwitchToDialog( dialog, ... );

Often the code intended to present or switch the dialogs is found 'outside' of the actual dialog. In such case you will need to search for the actual dialog to access the values stored in it. You use the method FindCurrentDialog() in such case (see also Enumerate and search for existing Dialogs). For example:

// First search the entire UI for the current dialog. Note the type cast (Application::Component)
// to verify whether the dialog is of the expected class.
var Application::Component current = (Application::Component)GetRoot().FindCurrentDialog();

// There is no such dialog existing
if ( !current )
  return;

// Create a new instance of the component to present as new dialog.
var Application::Component dialog = new Application::Component1;

// Initialize the properties of the new dialog with values found in current dialog.
dialog.TestName = current.TestName;
dialog.ProdName = current.ProdName;
...

// Present a new dialog
GetRoot().PresentDialog( dialog, ... );

This is the common approach how to exchange data between components (also explained in the chapter Implementing component interface). Embedded Wizard provides however other techniques to achieve this. As mentioned by Manfred, instead of reading data from dialog A and writing the data to dialog B, you could follow the Mode-View-Controlled approach. In this model you store the data (e.g. TestName, ProdName, ...) as properties in a global objects. When a value is changed in Component A, your implementation updates the corresponding properties in the global object. When a new dialog is presented depending on the values, the dialog accesses the values from the global object.

To implement such approach:

Step B.1: Create first a new empty class. See also Creating non visual components.

Step B.2: Add to the class as many properties as values you want to store. Name and configure the data type of the properties. (similar to the steps A.1-A.3).

Step B.3: Create a global instance of the class as so called auto object. See also Create new autoobject.

Step B.4: Now your implementation of the dialogs can access the values found in the auto object. It can update the values:

// Store actual value found in a Test Name text field in a property of the autoobject
Application::DataObject.TestName = TestNameText.String;

... or read the values:

// Use the value found in the autoobject to initialize a text field
TestNameText.String = Application::DataObject.TestName;

In this manner you use the global object as data container to store and exchange data between several components.

I hope this outline helps you to find the right approach for your application case.

Best regards

Paul Banach

by
Hi Paul,

Thanks for your detailed answer. Now it is working but i have one more doubt that as you can see my previous question, you will find one DropDown, for that i have used ComboBox. How to access the option that i have selected in DropDown from Component to Component1?

Regards

Rangsons
by

Hello Rangsom,

I assume, with DropDown you refer the ComboBox component created from the provided component templates (see also Creating components from templates: Combo Box). In such case, the current selection in the ComboBox is determined by its property SelectedItem. This property has the data type int32.

As explained in my preceding comment, to exchange data with a component you implement an interface composed of properties. In the examples from my answer I limited to exchange strings (e.g. for the Text edit field Test Name). This approach can also be used to exchange int32 values. You could thus:

Step1: add a new property to your component and name it e.g. ProdType.

Step 2: Since we want integer to be exchanged via this property, you should configure its data type to int32.

Step 3: In the OnSet method just relay the assigned value to the ComboBox, for example:

// Relay the just assigned value to the ComboBox.
ComboBox.SelectedItem = value;

Step 4: In the OnGet method return the number of the item selected actually in the ComboBox, for example:

return ComboBox.SelectedItem;

Step 5: Then you use the new property ProdType to initialize and query the corresponding ComboBox selection, similarly to how it is explained with the TestName property in my preceding answer.

I hope it helps you further.

Best regards

Paul Banach

by
Hi Paul,

I dont want the SelectedItem integer values to be transferred, I want the OnLoadItem string values what i have selected in the DropDown Menu to be transferred to another screen.

Reagrds

Rangsons
by

Hello Rangsons,

in such case you want the content of the item selected actually in the ComboBox. For this purpose, use the SelectedItem property to query the number of the actually selected item. Then using this number you can determine the corresponding string - exact as you do in the OnLoadItem method. For example, the following could be the implementation of an OnGet method associated to some ProdType property: 

// Get the number of the actually selected item
var int32  item = ComboBox.SelectedItem;
var string content;

// Based on the number, get the content, here for example, using a
// switch case statement with hard coded contents:
switch ( item )
{
  case  0 : content = "Banana";
  case  1 : content = "Apple";
  case  2 : content = "Cherry";
  case  3 : content = "Strawberry";
  case  4 : content = "Pineapple";
  case  5 : content = "Orange";
  case  6 : content = "Kiwi";
  case  7 : content = "Blueberry";
  case  8 : content = "Melon";
  case  9 : content = "Mango";
  default : content = "???";
}

return content;

With the above code, each time the property ProdType is evaluated, the operation results in a string corresponding to the actual selection in the ComboBox. In the opposite direction, when a new string is assigned to the property ProdType, you will need to find the number of an item matching the assigned string. Following could be the implementation of the OnSet method associated to the property ProdType:

var int32 item;

// Compare the just assigned string with the values available in the ComboBox
// and find so the number of the corresponding item.
if      ( value == "Banana" ) item = 0;
else if ( value == "Apple"  ) item = 1;
else if ( value == "Cherry" ) item = 2;
...

// Select the item in the ComboBox
ComboBox.SelectedItem = item;

The above examples assume the items for the ComboBox are hardcoded. I don't know your application case, but possibly the contents will be dynamic. In such case it can be more convenient to use an array to store the strings for the items. Then you don't need the switch-case code and just access the array. Also the above implementation of the OnSet method can be simplified by using a for-loop to iterate over the array items and so find the one matching the just assigned string.

I hope it helps you further.

Best regards

Paul Banach

by
Thanks Paul, It is working fine

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

...