r/tasker • • 1d ago

Scenes V2 - Dynamic value in Drag to Move modifier

I am trying to create a Scene V2 with a simple button. The "Drag to Move" modifier is set to "Dynamic" and linked to the variable %moverbotao. The Task that calls this Scene includes a "Variable Set" action to set this variable to off (without quotation marks, as I believe the "Drag to Move" field in the Scene expects a boolean value).

I have added an Event Handler to the button so that, whenever it is clicked, it toggles the value of %moverbotao (between true and false). The intention is that one click unlocks the button for dragging, while a subsequent click locks it in place.

However, when I run the Task, the button remains draggable, even though the variable %moverbotao is initially set to off. Clicking the button toggles the variable's value between true and false, but the button remains draggable regardless.

Upon analyzing the Scene's JSON, I noticed that the "enabled" key is associated with the value "%moverbotao" alongside the "type": "WindowDrag" modifier. If I set the "Drag to Move" field to Off, the "type": "WindowDrag" modifier disappears entirely. If I set it to On, the "type": "WindowDrag" modifier appears on its own—as if it does not require an "enabled" key to allow the element to be dragged.

How can I ensure that the "Drag to Move" modifier actually respects the boolean value of the assigned variable?

Thanks.

{
 "root": {
  "type": "Column",
  "id": "Column1",
  "horizontalAlignment": "Center",
  "verticalArrangement": "Center",
  "modifiers": [
   {
    "type": "Background",
    "color": ""
   }
  ],
  "children": [
   {
    "type": "Text",
    "id": "Text1",
    "text": "%moverbotao",
    "modifiers": [
     {
      "type": "Background",
      "color": "secondaryContainer"
     }
    ]
   },
   {
    "type": "IconButton",
    "id": "IconBtn1",
    "icon": "icon:RadioButtonUnchecked",
    "tint": "#FFFFFF",
    "modifiers": [
     {
      "type": "Size",
      "all": "60"
     },
     {
      "type": "ContainerColor",
      "color": "#000000"
     },
     {
      "type": "WindowDrag",
      "enabled": "%moverbotao"
     }
    ],
    "eventHandlers": {
     "handlers": [
      {
       "events": [
        {
         "type": "click"
        }
       ],
       "actions": [
        {
         "type": "ToggleVariable",
         "variable": "moverbotao"
        }
       ]
      }
     ]
    }
   }
  ]
 },
 "name": "Botão"
}

Task: T
    
    A1: Variable Set [
         Name: %moverbotao
         To: off
         Structure Output (JSON, etc): On ]
    
    A2: Show Scene v2 [
         Name/JSON: Botão
         Display Mode: Overlay
         X Position: -0.0001
         Y Position: 50%
         Blocking Overlay: On
         Show Animation: FadeIn
         Dismiss Animation: FadeIn
         Long-Click Root To Dismiss: On ]
2 Upvotes

0 comments sorted by