# Slider not responding to value

**URL:** <https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719>\
**Category:** Photoshop\
**Created:** [January 19, 2023, 4:57pm UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719 "2023-01-19T16:57:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [January 19, 2023, 4:57pm UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719/1 "2023-01-19T16:57:28Z")

</div>

Hey!  
I’m trying to create a slider for some adjustments, passing the values to the function parameters using batchPlay, however, I don’t know how to make it work correctly when sliding return to the left.  
In extendScript use `doc.activeHistoryState = currentStatus`; at the start of the function.  
All help is appreciated

 ![sssssss](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/b/beb8adf6f91b4030fd8fd4ad7743b20160df5988.png)

html

```auto
<sp-slider id="ajustRed" size="s" min="-100" max="100" value="0" style="width: 160px;"> <sp-label slot="label">Vermelho</sp-label> </sp-slider>

```

js

```auto
document.querySelector("#ajustRed").addEventListener("change", async (func) => {
   await core.executeAsModal(async () => {ajustRed(func.target.value);})
})

async function ajustRed(valor){
   await app.batchPlay([{"_obj":"colorBalance","highlightLevels":[0,0,0],"midtoneLevels":[valor,0,0],"preserveLuminosity":true,"shadowLevels":[0,0,0]}],{});
}

```

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [January 20, 2023, 1:27am UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719/2 "2023-01-20T01:27:26Z")

</div>

Can anyone show me how a slider works in UXP?

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [January 20, 2023, 7:07am UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719/3 "2023-01-20T07:07:43Z")

</div>

Did you try [searching the forum](http://forums.creativeclouddeveloper.com/search?q=sp-slider%20change%20event)?

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [January 20, 2023, 11:59am UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719/4 "2023-01-20T11:59:28Z")

</div>

> [@Karmalakas](#):
>
> Você tentou [pesquisar no fórum](http://forums.creativeclouddeveloper.com/search?q=sp-slider%20change%20event) ?

@Karmalakas, I searched everything in this forum, I found everything about slide except what I really need.  
See the video that works partially, but does not work as it should.  
What am I doing wrong?

here is my code  
html

```auto
<sp-slider id="ajRed" size="s" min="-100" max="100" value="0" style="width: 160px;"> <sp-label slot="label">Ajuste Red</sp-label> </sp-slider>
<sp-slider id="ajBlur" size="s" min="0" max="100" value="0" style="width: 160px;"> <sp-label slot="label">Gaussian blur</sp-label> </sp-slider>

```

js

```auto
document.querySelector("#ajRed").addEventListener("change", async (func) => {
   await core.executeAsModal(async () => {ajustRed(func.target.value);})
}) 

document.querySelector("#ajBlur").addEventListener("change", async (func) => {
	await core.executeAsModal(async () => {ajustGBlur(func.target.value);})
 }) 

async function ajustRed(valor){
     await app.batchPlay([{"_obj":"colorBalance","midtoneLevels":[valor,0,0]}],{});
}

async function ajustGBlur(valor){
    await app.batchPlay([{"_obj":"gaussianBlur","radius":{"_unit":"pixelsUnit","_value":valor}}],{});
}

```

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [January 20, 2023, 1:17pm UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719/5 "2023-01-20T13:17:14Z")

</div>

Based on what I see, you’re applying blur on a blur. I don’t think you can unblur the blur. What I mean, is you blur the pixels with value 75 for example and then reduce slider to 25 - that still blurs the pixels which are already blurred. I guess you’d need to convert layer to smart object first and then change blur value, so you could reduce blur after the fact

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [January 20, 2023, 1:48pm UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719/6 "2023-01-20T13:48:23Z")

</div>

Great solution, at first it works well, but for it to work 100%, I’ll have to add an if/else, because this only works if the blur effect is already applied to the layer, do you agree? Would you know the correct syntax to check if a smart object has a specific effect applied? Like a blur? Thanks for the support, when I grow up I want to be just like you.

---

<div class="post-metadata">

**Author:** ![Wanokuni](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/wanokuni/32/2203_2.png) [@Wanokuni](https://forums.creativeclouddeveloper.com/u/Wanokuni)\
**Post date:** [January 20, 2023, 6:37pm UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719/7 "2023-01-20T18:37:32Z")

</div>

Here you go, this code will check if select layer is smart object and which filter is applied to it. You should use [Alchemist Plugin](https://github.com/jardicc/alchemist) it will save you a lot of time.

```auto
 const batchPlay = require("photoshop").action.batchPlay;
    const layerKind = app.activeDocument.layers[0].kind;
    if (layerKind === "smartObject") {

      const result = await batchPlay(
        [
          {
            _obj: "get",
            _target: [
              {
                _property: "smartObjectMore",
              },
              {
                _ref: "layer",
                _id: app.activeDocument.activeLayers[0]._id,
              },
              {
                _ref: "document",
                _id: app.activeDocument?.id,
              },
            ],
            _options: {
              dialogOptions: "dontDisplay",
            },
          },
        ],
        {}
      );

      const pinned = result[0].smartObjectMore.filterFX.filterFXList[0];
      console.log(pinned.filter);
    } else {
      // select layer is not a smart object
      require("photoshop").core.showAlert(
        "Please make sure the slected layer is a smart object"
      );
    }

```

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [January 21, 2023, 11:46pm UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719/8 "2023-01-21T23:46:12Z")

</div>

> [@Wanokuni](#):
>
> `filterFX.filterFXList[0]`

@Wanokuni Thanks for the code! Taking the opportunity, would you know how to get the value of filterFX?

---

<div class="post-metadata">

**Author:** ![Wanokuni](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/wanokuni/32/2203_2.png) [@Wanokuni](https://forums.creativeclouddeveloper.com/u/Wanokuni)\
**Post date:** [January 22, 2023, 12:50pm UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719/9 "2023-01-22T12:50:20Z")

</div>

Use the code I wrote above with the Dev Tool to view the available parameters.

 ![Screenshot 2023-01-22 at 14.36.23](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/b/bf8ea7d677f50201ebba949e77bda0d330212b20.png)

```auto
  const pinned = result[0].smartObjectMore.filterFX.filterFXList[0];
  const filterValue = pinned.filter.radius._value;
  console.log(pinned.filter);
 console.log("Filter value", filterValue);

```

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [January 22, 2023, 2:23pm UTC](https://forums.creativeclouddeveloper.com/t/slider-not-responding-to-value/5719/10 "2023-01-22T14:23:44Z")

</div>

@Wanokuni Thank you for providing me with this precious information.
