In an app, my goal is to have a button run a method in the same app.
Below is some code I found on this forum. And I think it tells the answer but I also think I'm missing something.
Question:
In the line:
input(name: "pauseButton", type: "button", title: "Pause",
The type being "button" results in the execution of the below method:
def appButtonHandler(btn) {
This suggests the type: "button" kind of relates to "btn" as the parameter passed to "def appButtonHandler(btn)"
Do I have this correct? I was not able to find anything in the documentation.
Thanks
John
section(){
if (!state.isPaused) {
input(name: "pauseButton", type: "button", title: "Pause", backgroundColor: "Green", textColor: "white", submitOnChange: true)
} else {
input(name: "resumeButton", type: "button", title: "Resume", backgroundColor: "Crimson", textColor: "white", submitOnChange: true)
}
}
.
.
.
.
def appButtonHandler(btn) {
switch(btn) {
case "pauseButton":
state.isPaused = true
break
case "resumeButton":
state.isPaused = false
break
}
updated()
}