How Edit Control works actually
#1
Hi,

I don't undestand how to attach a setting value to an edit control.

Defining the control is fine, but how to store the entered value and how to retrieve it into the control ?

Thanks
Reply
#2
Ok, I partly answer my own question,

I found out how to save data, not automatically, unfortunately, with a button you have to click on :
Code:

        <control type="button" id="790">
            <visible>Container(9000).HasFocus(5)</visible>
            <label>$LOCALIZE[190]</label>
            <right>20</right>
            <bottom>60</bottom>
            <width>220</width>
            <height>70</height>
            <onup>640</onup>
            <ondown>640</ondown>
            <onleft>9000</onleft>
            <align>center</align>
            <aligny>center</aligny>
            <invalidcolor>invalid</invalidcolor>
            <selectedcolor>selected</selectedcolor>
            <texturefocus colordiffuse="button_focus">lists/focus.png</texturefocus>
            <texturenofocus colordiffuse="dialog_tint">colors/white.png</texturenofocus>
            <onclick>Skin.SetString(SpecialFolder01, $INFO[Control.GetLabel(740).Index(1)])</onclick>
            <onclick>Skin.SetString(SpecialFolder02, $INFO[Control.GetLabel(741).Index(1)])</onclick>
            <onclick>Skin.SetString(SpecialFolder03, $INFO[Control.GetLabel(742).Index(1)])</onclick>
            <onclick>Skin.SetString(SpecialFolder04, $INFO[Control.GetLabel(743).Index(1)])</onclick>
            <onclick>Skin.SetString(SpecialFolder05, $INFO[Control.GetLabel(744).Index(1)])</onclick>
        </control>

I can retrieve data with
Code:
Skin.String(SpecialFolder01)
However, I cannot set the Label2 of the edit control to retrieve previous value. This do not work :
Code:

                <control type="edit" id="740">
                    <include content="DefaultSettingButton">
                        <param name="textoffsetx" value="0" />
                    </include>
                    <label>$LOCALIZE[19076]   1</label>
                    <label2>$INFO[Skin.String(SpecialFolder01)]</label2>
                </control>
So, when the page is loaded, my five edit controls are empty despite the settings get the values. If I click on my save button without typing or changing any value, all settings are cleaned (obviously, as label2 are not defined).

Someone to help please on how get this
Code:
<label2>$INFO[Skin.String(SpecialFolder01)]</label2>
working in some way ? and eventually on how to "auto-save" edit control without any button.

Thanks
Reply
#3
You can't set the value of an edit control without a script.

You can use skinvariables script to set an edit control:
https://github.com/jurialmunkey/script.s...rol-script
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#4
Thanks,
This is seems great, however, I have some problems :
I have tried to load labels with a button (I would have preferred that labels would have loaded automatically - I don't know if this is possible) :
Code:

        <control type="button" id="790">
            <visible>Container(9000).HasFocus(5) + String.IsEmpty(Control.GetLabel(740).Index(1))</visible>
            <label>$LOCALIZE[31903]</label>
            <right>20</right>
            <bottom>60</bottom>
            <width>220</width>
            <height>70</height>
            <onup>640</onup>
            <ondown>640</ondown>
            <onleft>9000</onleft>
            <align>center</align>
            <aligny>center</aligny>
            <invalidcolor>invalid</invalidcolor>
            <selectedcolor>selected</selectedcolor>
            <texturefocus colordiffuse="button_focus">lists/focus.png</texturefocus>
            <texturenofocus colordiffuse="dialog_tint">colors/white.png</texturenofocus>
            <enable>String.IsEmpty(Control.GetLabel(740).Index(1))</enable>
            <onclick>RunScript(script.skinvariables,set_editcontrol=740,text=$INFO[Skin.String(SpecialFolder01)])</onclick>
            <onclick>RunScript(script.skinvariables,set_editcontrol=741,text=$INFO[Skin.String(SpecialFolder02)])</onclick>
            <onclick>RunScript(script.skinvariables,set_editcontrol=742,text=$INFO[Skin.String(SpecialFolder03)])</onclick>
        </control>

However, only Control 740 is defined.... with the control 742 value Sad

I had a look to your code. I am absolutely not a python dev, however I know coding (C++, C#), so I can vaguely understand how it works Smile
I see that you are focusing the edit control before sending text to it. I don't know why, but the SetFocus method seems to work randomly with Id.

I tried this also to set focus on parent (control 640) after defining the label2 :
Code:

            <onclick>RunScript(script.skinvariables,set_editcontrol=740,text=$INFO[Skin.String(SpecialFolder01)],setfocus=640,setfocus_wait=00:00)</onclick>
            <onclick>RunScript(script.skinvariables,set_editcontrol=741,text=$INFO[Skin.String(SpecialFolder02)],setfocus=640,setfocus_wait=00:00)</onclick>
            <onclick>RunScript(script.skinvariables,set_editcontrol=742,text=$INFO[Skin.String(SpecialFolder03)],setfocus=640,setfocus_wait=00:00)</onclick>
and that to set focus on next edit control :
Code:

            <onclick>RunScript(script.skinvariables,set_editcontrol=740,text=$INFO[Skin.String(SpecialFolder01)],setfocus=741,setfocus_wait=00:00)</onclick>
            <onclick>RunScript(script.skinvariables,set_editcontrol=741,text=$INFO[Skin.String(SpecialFolder02)],setfocus=742,setfocus_wait=00:00)</onclick>
            <onclick>RunScript(script.skinvariables,set_editcontrol=742,text=$INFO[Skin.String(SpecialFolder03)],setfocus=743,setfocus_wait=00:00)</onclick>
with no luck.

Yesterday, while I was looking to set label2 directly into the edit control, I found this setLabel method for edit control, but, as I said, I don't know python and I don't know if it is still usable in Nexus, nor if the label2 param could work. Apparently, the drawback is you need to define many params already setted.
After testing, last one seems not to be the way, label2 is not set despite the syntax would let you think it can.

May be I should add that each edit control is inside a grouplist control.
Reply
#5
After many tests, when there is only one edit control, your script is working perfectly.

However, with more than one edit control, it is not : above codes are randomly selected an edit control between the ones defined (740, 741, ...), then set it the text with all the values (replaced one by one, which means that you can see one of the values - not always the first one - then it is replaced by another one, and so on... the last one is not always the right value).

Any idea ?

Thanks
Reply
#6
Yeah you need to be able to run the command sequentially rather than in parallel, otherwise it creates a race condition where they steal focus from each other.

You can setup a chain. Create a folder in the skin basedir called "builtins" and then a text file e.g. skinvariables-setedit.json with the content

json:

{
"infolabels": {
"text01": "Skin.String(SpecialFolder01)",
"text02": "Skin.String(SpecialFolder02)",
"text03": "Skin.String(SpecialFolder03)"
},
"actions": [
"route=set_editcontrol=740&text={text01}]",
"route=set_editcontrol=741&text={text02}]",
"route=set_editcontrol=742&text={text03}]",
"SetFocus(640)"
]
}

Then you can run this file with
Code:

<onclick>RunScript(script.skinvariables,run_executebuiltin=special://skin/builtins/skinvariables-setedit.json,use_rules)</onclick>
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#7
Thanks, unfortunately, this is not working Sad

The only thing it does is setting the focus on the last edit control, no text is loaded for any edit control.

I have created the "builtins" folder as is :
skin.myskin
      builtins
      colors
      fonts
      language
      ...
      xml
Reply
#8
Sorry I made a typo the square bracket at the end ] needs to be removed e.g. on these lines:
"route=set_editcontrol=740&text={text01}]",

should be

"route=set_editcontrol=740&text={text01}",


You might also need to add a wait between each command e.g.
"sleep=0.2",
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#9
I saw your typo error, but this did not worked either.

The sleep command was needed, however this weirdly conducted to this
Control 740 got #1 value -> Control 740 replaced by #2 value -> Control 741 got #3 value -> Control 742 got #4 value -> Control 743 got #5 value -> Control 744 got focus with no value.

I had to modify the json file so that Control 740 is defined a second time at the end and the set focus to next edit control is done :
Code:

{
    "infolabels": {
        "text01": "Skin.String(SpecialFolder01)",
        "text02": "Skin.String(SpecialFolder02)",
        "text03": "Skin.String(SpecialFolder03)",
        "text04": "Skin.String(SpecialFolder04)",
        "text05": "Skin.String(SpecialFolder05)"
    },
    "actions": [
        "sleep=0.2",
        "route=set_editcontrol=740&text={text01}&setfocus=741&setfocus_wait=00:00",
        "sleep=0.2",
        "route=set_editcontrol=741&text={text02}&setfocus=742&setfocus_wait=00:00",
        "sleep=0.2",
        "route=set_editcontrol=742&text={text03}&setfocus=743&setfocus_wait=00:00",
        "sleep=0.2",
        "route=set_editcontrol=743&text={text04}&setfocus=744&setfocus_wait=00:00",
        "sleep=0.2",
        "route=set_editcontrol=744&text={text05}&setfocus=740&setfocus_wait=00:00",
        "sleep=0.2",
        "route=set_editcontrol=740&text={text01}",
        "sleep=0.2",
        "SetFocus(640)"
    ]
}

THANKS A LOT Smile
Reply

Logout Mark Read Team Forum Stats Members Help
How Edit Control works actually0