Cabbage Logo
Back to Cabbage Site

Image switcher, only works when note pressed

I’m trying to have a combo box allow the user to switch between different background images. I’ve got it working halfway - it does change the image but only once the keyboard is pressed rather than changing when the combo box selection is changed.

I’ve been really confused as to what I’m doing wrong here so any help is appreciated.

Thanks!

Here’s the code:
bounds(0, 0, 0, 0)
form caption(“Chinchilla Image Test”) size(1000, 540), guiMode(“queue”), pluginId(“def1”) bundle("./imgs")
image bounds(0, 0, 1000, 540) channel(“image1”) file("./imgs/Kirby1.jpg") visible(1)
image bounds(0, 0, 1000, 540) channel(“image2”) file("./imgs/Kirby2.jpg") visible(0)
image bounds(0, 0, 1000, 540) channel(“image3”) file("./imgs/Kirby3.jpg") visible(0)
combobox bounds(902, 434, 80, 20) channel(“imagebox”) text(“Kirby1”, “Kirby2”, “Kirby3”)
keyboard bounds(294, 444, 368, 60)

instr 1
kpic chnget “imagebox”
ktrig changed kpic
if ktrig==1 then
reinit RESTART
endif

RESTART:
if chnget:k(“imagebox”) == 1 then
cabbageSet ktrig, “image1”, “visible”, 1
else
cabbageSet ktrig, “image1”, “visible”, 0
endif
if chnget:k(“imagebox”) == 2 then
cabbageSet ktrig, “image2”, “visible”, 1
else
cabbageSet ktrig, “image2”, “visible”, 0
endif
if chnget:k(“imagebox”) == 3 then
cabbageSet ktrig, “image3”, “visible”, 1
else
cabbageSet ktrig, “image3”, “visible”, 0
endif
endin

ImageTest.zip (78.4 KB)

Sorry, I can’t check this properly as I’m currently taking a short vacation, but you should put your UI coffee into an instrument that is always on rather than one that is triggered via the midi controller…

because you r telling cabbage to reinit the image when you hit a key
if ktrig==1 then
reinit RESTART

1 Like

Ohh thank you so much!