Gallery of UIs written in MQL - page 64

 

9. Returns the previous value of _V_LAST .

The previous value of all parameters is saved automatically. To get it, you need to call the element function and pass the _V_LAST identifier .

Let's see how it is done on a practical example:

1. Open the desired window:

   //------------------------------------------------
   //Open the window "Settings example 2".

   w_7_Settings_example_2();
   //------------------------------------------------



2. Send a value (character string) to the upper input field:

   //------------------------------------------------
   //Set up the first string in the textbox:

   w7_s_p4_EDIT_Comment_1("1, 2, 3, 4, 5");
   //------------------------------------------------



3. Now send another string to the same field:

   //------------------------------------------------
   //Right after, reset it by the new string:

   w7_s_p4_EDIT_Comment_1("A, B, C, D, E");
   //------------------------------------------------



4. We get the previous string back:

   //------------------------------------------------
   //Get back the first value:

   string The_first_value = w7_s_p4_EDIT_Comment_1(get_s,p4_V_LAST);
   //------------------------------------------------


5. And send it to the field below:

   //------------------------------------------------
   //And send it into the textbox below:

   w7_s_p4_EDIT_Comment_2(The_first_value);
   //------------------------------------------------


6. Let's rewrite the top field line again:

   //------------------------------------------------
   //Reset the value again:

   w7_s_p4_EDIT_Comment_1("A1, B2, C3, D4, E5");
   //------------------------------------------------


7. Let's send the previous string to the lower field:

   //------------------------------------------------
   //And get the the previous value back:

   string The_second_value = w7_s_p4_EDIT_Comment_1(get_s,p4_V_LAST);
   //------------------------------------------------
   
   //------------------------------------------------
   //Send it into the third textbox:

   w7_s_p4_EDIT_Comment_3(The_second_value);
   //------------------------------------------------



Result:

  • The top field is the current string.
  • In the middle field - the original string.
  • In the bottom field - the second string.

//--------------------------------------------------------------------------------------------------------------------------

The same approach works in all cases.

Using the _V_LAST identifier, you can get the last value of any elements (if the identifier is prescribed in the list of individual properties).




Next, consider setting ON/OFF states and locking elements.

 
Реter Konow #:
The same approach works in all cases.

Does it also include ON/OFF status?

 
hini #:

Does it also include an ON/OFF state?

_V_LAST returns the last parameter value of any element.

You can use the approach shown above for other elements. I will show the example of a slider and a field with buttons after the topic of switching element states.

When we look at synchronisation, one field will return the current value of the slider and the other will return the previous value.

 

10.SettingON, OFF, LOCK_ON, LOCK_OFF, LOCK, UNLOCKstatesfor different elements:

There are types of elements that haveON and OFF states, the classic example being buttons and checkboxes. However, there are many elements that are always in a neutral state. AlwaysOFF. What do they have in common with buttons and checkboxes? Both can belocked and unlocked. The difference is thatbuttons and checkboxes are locked in two states - on and off, while the other elements are only inneutral. Because of these differences there are several identifiers that perform the same function - they lock and unlock elements.

Let's consider some practical examples:

1. Let's open the settings window with buttons and checkboxes:

   //------------------------------------------------
   //Open the window "Settings example 1".
   //------------------------------------------------
   w_6_Settings_example_1();
   //------------------------------------------------



2. Let's set the enabled state for the button:

   //------------------------------------------------
   //Set the button "Start" ON:

   w6_i_p1_BUTTON_Start(p1_ON);
   //------------------------------------------------

Result: the button has switched to the pressed state.


3. Now, set theON state for the checkboxes:

   //------------------------------------------------
   //Set the checkboxes ON:

   w6_i_p7_CHECKBOX_Set_an_option(p7_ON);
   w6_i_p7_CHECKBOX_Set_another_option(p7_ON);
   w6_i_p7_CHECKBOX_And_another_option(p7_ON);
   //------------------------------------------------

Result: The checkboxes have moved to the activated state.

//----------------------------------------------------------------------------------------------------------------------


4. Now, let's remove the ON state from the "Start" button using theOFF identifier:

   //------------------------------------------------
   //Set the button "Start" OFF:

   w6_i_p1_BUTTON_Start(p1_OFF);
   //------------------------------------------------

Result: the button has returned to the neutral state.


5. Let's return the neutralOFF state to the checkboxes :

   //------------------------------------------------
   //Set the checkboxes OFF:
 
   w6_i_p7_CHECKBOX_Set_an_option(p7_OFF);
   w6_i_p7_CHECKBOX_Set_another_option(p7_OFF);
   w6_i_p7_CHECKBOX_And_another_option(p7_OFF);
   //------------------------------------------------

Result: the checkboxes have returned to the neutral state.


//-------------------------------------------------------------------------------------------------------------------------


Now let's move on to locking the button and checkboxes in two possible states: neutral and activated:


1. Let's lock the button in the neutral state:

   //------------------------------------------------
   //Lock the button "Start" in the state OFF:

   w6_i_p1_BUTTON_Start(p1_LOCK_OFF);
   //------------------------------------------------

Result: button locked in neutral state.

(*fault, fix will be.).


2. Lock the checkboxes in the neutral state:

   //------------------------------------------------
   //Lock the checkboxes in the state OFF:

   w6_i_p7_CHECKBOX_Set_an_option(p7_LOCK_OFF);
   w6_i_p7_CHECKBOX_Set_another_option(p7_LOCK_OFF);
   w6_i_p7_CHECKBOX_And_another_option(p7_LOCK_OFF);
   //------------------------------------------------

Result: the checkboxes are locked in neutral state.


(*problem of text disappearing in locked state for some elements will be solved in the next version).


3. Lock the button and checkboxes in the pressed state using theLOCK_ON identifier:

   //------------------------------------------------
   //Lock the button "Start" in the state ON:

   w6_i_p1_BUTTON_Start(p1_LOCK_ON);
   //------------------------------------------------
   //------------------------------------------------
   //Lock the checkboxes in the state ON:

   w6_i_p7_CHECKBOX_Set_an_option(p7_LOCK_ON);
   w6_i_p7_CHECKBOX_Set_another_option(p7_LOCK_ON);
   w6_i_p7_CHECKBOX_And_another_option(p7_LOCK_ON);
   //------------------------------------------------

Result: button and checkboxes are locked in the pressed state.



//--------------------------------------------------------------------------------------------------------

Now let's test theLOCK and UNLOCK commands for elements that are always in the neutral state.

For example, let's take the elementsC_LIST, D_LIST, H_SLIDER and S_EDIT in the same window:



1. Let's lock all four elements at once:

   //------------------------------------------------
   //Lock the elements:

   w6_s_p6_C_LIST_C_LIST_1(p6_LOCK);
   w6_s_p6_D_LIST_D_LIST_1(p6_LOCK);
   w6_i_p3_H_SLIDER_Roll_the_value(p3_LOCK);
   w6_d_p5_S_EDIT_Spin_the_value(p5_LOCK);
   //------------------------------------------------

Result: the elements C_LIST, D_LIST, H_SLIDER and S_EDIT are locked .


2. Unlock the elements:

   //------------------------------------------------
   //Unlock the elements:

   w6_s_p6_C_LIST_C_LIST_1(p6_UNLOCK);
   w6_s_p6_D_LIST_D_LIST_1(p6_UNLOCK);
   w6_i_p3_H_SLIDER_Roll_the_value(p3_UNLOCK);
   w6_d_p5_S_EDIT_Spin_the_value(p5_UNLOCK);
   //------------------------------------------------

Result: the elements have been unlocked back.

//-------------------------------------------------------------------------------------

With these examples we conclude this topic, as the other elements are locked and unlocked in the same way.

...

Next we move on to synchronisation of parameter values.

 
Very good, very practical.
 
hini #:
Very good, very practical.

Thank you! User evaluation is very important for further development.

 
Having weighed up the amount of material for the next topic, I think it would be better to postpone it until tomorrow so that the previous topics are better remembered.
 

Signs of a good GUI.

Minimalism: minimum space occupied on the graphics, absence of insignificant elements and information that distract attention.

Functionality: all space occupied should be as useful as possible, all functions should be intuitive.

Ergonomics: the most frequently used elements should be accessible and large.

Aesthetics: alignment, standard sizes, uniform style, colour scheme.

 
Ivan Titov #:

Signs of a good GUI.

Minimalism: minimum space occupied on the graphics, absence of insignificant elements and information distracting attention.

Functionality: all space occupied should be as useful as possible, all functions should be intuitive.

Ergonomics: the most frequently used elements should be accessible and large.

Aesthetics: alignment, standard dimensions, uniform style, colour scheme.


Thanks for showing the example. I completely agree with your theses. I hope to reach this level of development eventually.
 
Реter Konow #:
SetON, OFF, LOCK_ON, LOCK_OFF, LOCK, UNLOCKstatus for different elements

How to get the on/off state of a button?