# toFront()?

**URL:** <https://forum.cabbageaudio.com/t/tofront/3526>\
**Category:** Cabbage Stew\
**Created:** [27 December 2022 12:45 UTC](https://forum.cabbageaudio.com/t/tofront/3526 "2022-12-27T12:45:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![iainmccurdy](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/i/8baadc/32.png) [@iainmccurdy](https://forum.cabbageaudio.com/u/iainmccurdy)\
**Post date:** [27 December 2022 12:45 UTC](https://forum.cabbageaudio.com/t/tofront/3526/1 "2022-12-27T12:45:40Z")

</div>

I was trying to make use of the `toFront()` identifier. I was hoping that the following would alternate bringing the red and blue circles to the front, so any advice on how to get this working would be very much appreciated.

```
<Cabbage>
form caption("Untitled") size(700, 200), guiMode("queue"), pluginId("def1")
image bounds(200,50,100,100), channel("red"), colour("red"), shape("ellipse")
image bounds(250,50,100,100), channel("blue"), colour("blue"), shape("ellipse")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -dm0
</CsOptions>
<CsInstruments>
0dbfs = 1

instr 1
schedkwhen metro:k(1,0 ),0,0,2,0,0
schedkwhen metro:k(1,0.5),0,0,3,0,0
endin

instr 2
print p1
cabbageSet "red","toFront"
endin

instr 3
print p1
cabbageSet "blue","toFront"
endin

</CsInstruments>
<CsScore>
i 1 0 z
</CsScore>
</CsoundSynthesizer>
```

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [28 December 2022 18:27 UTC](https://forum.cabbageaudio.com/t/tofront/3526/2 "2022-12-28T18:27:30Z")

</div>

Hi Iain. Sorry for the delay in getting back to you. Looks like a forgotten identifier. I’ll fix this tomorrow if I get a chance.

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [28 December 2022 18:44 UTC](https://forum.cabbageaudio.com/t/tofront/3526/3 "2022-12-28T18:44:09Z")

</div>

This is fixed now Iain. 👍

---

<div class="post-metadata">

**Author:** ![iainmccurdy](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/i/8baadc/32.png) [@iainmccurdy](https://forum.cabbageaudio.com/u/iainmccurdy)\
**Post date:** [29 December 2022 17:24 UTC](https://forum.cabbageaudio.com/t/tofront/3526/4 "2022-12-29T17:24:24Z")

</div>

Thanks, Rory. This seems to work fine now.

On a related topic, should `moveBehind(widgetName)` be the converse of this, with widgetName being the channel name of the widget the messaged widget should move behind?

The following seems to work once, i.e.: blue moves behind red, then red moves behind blue, but that’s it, whereas is should continue toggling.

```
<Cabbage>
form caption("Untitled") size(700, 200), guiMode("queue"), pluginId("def1")
image bounds(200,50,100,100), channel("red"), colour("red"), shape("ellipse")
image bounds(250,50,100,100), channel("blue"), colour("blue"), shape("ellipse")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -dm0
</CsOptions>
<CsInstruments>
0dbfs = 1

instr 1
schedkwhen metro:k(1,0 ),0,0,2,0,0
schedkwhen metro:k(1,0.5),0,0,3,0,0
endin

instr 2
print p1
cabbageSet "blue","moveBehind","red"
endin

instr 3
print p1
cabbageSet "red","moveBehind","blue"
endin

</CsInstruments>
<CsScore>
i 1 0 z
</CsScore>
</CsoundSynthesizer>
```

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [29 December 2022 19:31 UTC](https://forum.cabbageaudio.com/t/tofront/3526/5 "2022-12-29T19:31:45Z")

</div>

I think the issue here is that the identifier listeners in Cabbage all listen for changes. In this case, moveBehind is not changing from _red_ or _blue_, for channels _blue_ and _red._ I’m looking for a way to fix it, toFront() works because I fool it into thinking something has updated.

---

<div class="post-metadata">

**Author:** ![iainmccurdy](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/i/8baadc/32.png) [@iainmccurdy](https://forum.cabbageaudio.com/u/iainmccurdy)\
**Post date:** [29 December 2022 19:34 UTC](https://forum.cabbageaudio.com/t/tofront/3526/6 "2022-12-29T19:34:43Z")

</div>

To be honest, toFront() is probably sufficient - and a useful addition, I just thought I’d test out the other.

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [29 December 2022 19:36 UTC](https://forum.cabbageaudio.com/t/tofront/3526/7 "2022-12-29T19:36:27Z")

</div>

It’s fixed now at any rate. I just used the same approach I took with toFront() 👍
