User Tools

Site Tools


en:template:choice_input

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:template:choice_input [2016/08/10 17:14]
Nicolas Ronvel
en:template:choice_input [2017/07/19 13:24]
Nicolas Ronvel [Sharing Options]
Line 43: Line 43:
 You can use specific [[Advanced_String_Variables#​dropdown_menu|Advanced Variables]] to access the images of the selected option. You can use specific [[Advanced_String_Variables#​dropdown_menu|Advanced Variables]] to access the images of the selected option.
  
 +===== Content in options =====
 +
 +Since the release of the Beta 3, **Content** can be added to an option. For this purpose, add the property ''​content''​ to an option. The value has to be a portion of canvas code : an path, a textbox, a group of paths, ...
 +
 +<code javascript>​
 +{ "​name":​ "​icons",​ "​label":​ "​Icons",​ "​type":​ "​options",​ "​default":​ "​none",​ "​options":​
 +  [{
 +    "​option":​ "​none", ​ "​text":​ "​None",​
 +    "​content":​ [{ "​type":​ "​path","​path":​ [] }]
 +   }, {
 +    "​option":​ "​alignment-good",​ "​text":​ "​Alignment - Good",
 +    "​content":​ [{ "​type":​ "​path",​ "​path":​ "​./​js/​templates/​align-good.svg"​ }]
 +   }, {
 +    "​option":​ "​alignment-neutral",​ "​text":​ "​Alignment - Neutral",​
 +    "​content":​ [{ "​type":​ "​path",​ "​path":​ "​./​js/​templates/​align-neutral.svg"​ }]
 +   }, {
 +    "​option":​ "​alignment-evil",​ "​text":​ "​Alignment - Evil",
 +    "​content":​ [{ "​type":​ "​path",​ "​path":​ "​./​js/​templates/​align-evil.svg"​ }]
 +   }
 +},
 +</​code>​
 +
 +If you have defined a ''​content''​ property on an option, you can retrieve its content by using the ''​£optionsName''​ variable : 
 +
 +<code javascript>​
 +{
 +  "​type":​ "​path-group",​
 +  "​id":​ "​icon",​
 +  "​left":​ 9,
 +  "​top":​ 7,
 +  "​fill":​ "​$color1.hexa$",​
 +  "​paths":​ "​£icons"​
 +}
 +</​code>​
 ===== Sharing Options ===== ===== Sharing Options =====
  
Line 94: Line 128:
  
 This is much simpler, easier to update (just change one option), and it will result in lighter template (a little bit). This is much simpler, easier to update (just change one option), and it will result in lighter template (a little bit).
 +
 +==== Filtering the options ====
 +
 +Maybe you don't want all the options on one particular field ? Well, it's possible. For this instance, the ''​sharedOptions''​ property in the field will be an object with a key and the list of displayed options for this field. It will use a filtered version of the complete list from the sharedOptions :
 +
 +<code javascript>​
 +"​fields":​ [
 +    {
 +        "​name":​ "​ability1",​ "​label":​ "​Ability 1", "​type":​ "​options",​ "​default":​ "​d6",​ "​sharedOptions"​ : "​diceOptions"​
 +    },
 +    {
 +        "​name":​ "​ability2",​ "​label":​ "​Ability 2", "​type":​ "​options",​ "​default":​ "​d6", ​
 +        "​sharedOptions"​ : 
 +        { 
 +            "​key":​ "​diceOptions", ​
 +            "​options":​ [ "​d6",​ "​d8",​ "​d10"​ ] 
 +        }
 +    }
 +</​code>​
 +
 +In this example, the "​Ability 2" only provides three options : d6, d8 and d10. Those three options are specified in the ''​options''​ array, using the value of the option (''​option''​ property). The referenced sharedOption is found via the ''​key''​ property.
en/template/choice_input.txt · Last modified: 2017/07/19 13:24 by Nicolas Ronvel