question

Alexander Martin avatar image
Alexander Martin asked

Impossible to pass parameter as arguments array to TouchWrapper/SendEvent

I try to pass a parameter as arguments parameter to a TouchWrapper/SendEvent but it seems impossible.

Please find attached my latest try (with bind, I also tried without bind)

{
    "type": "APL",
    "version": "1.0",
    "theme": "dark",
    "import": [],
    "resources": [],
    "styles": {},
    "layouts": {
      "Button": {
        "parameters": [{
          "name": "arguments",
          "type": "array"
        }, {
          "name": "backgroundColor",
          "type": "color",
          "default": "#fff"
        }, {
          "name": "borderColor",
          "type": "color",
          "default": "#000"
        }, {
          "name": "text",
          "type": "string"
        }],
        "item": {
          "type": "TouchWrapper",
          "bind": [{
            "name": "args",
            "value": "${arguments}"
          }],
          "onPress": {
            "type": "SendEvent",
            "arguments": ["${args}"]
          },
          "item": {
            "type": "Frame",
            "borderWidth": 1,
            "borderRadius": 5,
            "borderColor": "${borderColor}",
            "backgroundColor": "${backgroundColor}",
            "item": {
              "type": "Container",
              "paddingTop": "4dp",
              "paddingRight": "4dp",
              "paddingBottom": "4dp",
              "paddingLeft": "4dp",
              "alignItems": "center",
              "justifyContent": "center",
              "items": [
                {
                  "type": "Text",
                  "text": "${text}"
                }
              ]
            }
          }
        }
      }
    },
    "mainTemplate": {
        "items": [{
            "type": "Button",
            "arguments": ["bar"],
            "text": "Foo"
        }]
    }
}

I also tried passing the args parameter in different ways:

  "arguments": "${args}" -> "arguments": []
  "arguments": ["${args}"] -> "arguments": ['["bar"]']

legend: input -> output in request

alexa skills kitalexaapl
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Arun@Amazon avatar image
Arun@Amazon answered

Hi

This looks like a bug. I have reported it. Can you tell me whether you're seeing this issue on the simulator and/or on a device. If it's a device, could you please provide the device serial number so we can ensure it has the latest version of the APL renderer.

Thanks

Arun

3 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Alexander Martin avatar image Alexander Martin commented ·

sorry! :) affected device is an echo show first generation, software version 622331120

0 Likes 0 ·

Hi, I have a similar problem trying to build my own button component.

I have been able to get a list of arguments but if those are defined from variables (for example "${param.property}") the ${} expression is not evaluated and is returned as a string. This doesn't happen if the argument is only one.

"arguments": ["eventID","${payload.item}"] -> "arguments": ["eventID", "${payload.item}"]
"arguments": "${payload.item}" -> "arguments": ["Item Content"]
0 Likes 0 ·
Alexander Martin avatar image Alexander Martin newuser-b63d2f37-3ebe-4be6-a5ef-bb974cb0797c commented ·

since I need sometimes more than a single argument I came up with the following workaround:

"arguments": ["${arg[0]}", "${arg[1]}", "${arg[2]}", "${arg[3]}", "${arg[4]}"]

keep in mind: if you pass an arg array like:

["foo"]

you will receive an event with at least 4 empty strings after the first argument "foo"

0 Likes 0 ·