-->
Page 1 of 2

Imagebutton not branching.

PostPosted: Tue May 10, 2016 8:51 am
by Electroguard
There appears to be a problem with imagebutton branching (Alpha24) - the instruction is recognised and displays the image, but if clicked, the specified branch is never reached. I've tried the branch with and without square brackets (the lang ref doesn't show sq brkts, but I guessed they are needed same as for the ordinary button instruction).

I cloned the identical non-working lines and converted them to ordinary buttons, which do work fine.
I've left both types of buttons so you can see in the example that clicking an ordinary button toggles the led and display the different image, but clicking the image does nothing because it never reaches the specified branch.

Any test pics should show the problem even if they are both the same.


Code: Select alllet pin = 1
let pinstatus = 1
po pin pinstatus

[home]
cls
if pinstatus == 0 then button "routerOFF.jpg" [toggle]
if pinstatus == 1 then button "routerON.jpg" [toggle]
if pinstatus == 0 then imagebutton "routerOFF.jpg" [toggle]
if pinstatus == 1 then imagebutton "routerON.jpg" [toggle]
wait

[toggle]
if pinstatus == 0 then pinstatus = 1 else pinstatus = 0
po pin pinstatus
'end ' uncommenting this proves that the imagebuttons never branch here, but the ordinary buttons do
goto [home] repaints the browser screen then waits for events
wait ' this is in case wait was required in the branch, but it wouldn't ever be reached here

Re: Imagebutton not branching.

PostPosted: Tue May 10, 2016 1:20 pm
by Electroguard
Should this work?
I've modded the IR example as minimally as possible just to try to send an image onclick to the [toggle] branch, but the image doesn't show a 'hand' when the cursor is over it, so I'm wondering if it's something I am doing wrong, or is it perhaps something to do with the imagebutton branch destination problem?


Code: Select alllet pin = 1
let stat = 1

html |<img onclick="sendIR('TOGGLE')" src="/file?file=nokia_rc202_2.jpg" alt="routeron" >  |
html |<script>|
html |function sendIR(key){  window.event.returnValue = false;  |
html |var xmlHttp = new XMLHttpRequest();  |
html |xmlHttp.open("GET", "msg?IR=" + key, false);  |
html |xmlHttp.send(null);  |
html |return xmlHttp.responseText;}|
html |</script>|

msgbranch [message]
wait

[message]
msgget "IR" k
if k = "TOGGLE" then gosub [toggle]
wait

[toggle]
if stat == 1 then stat = 0 else stat = 1
po pin stat
return

Re: Imagebutton not branching.

PostPosted: Tue May 10, 2016 5:19 pm
by Mmiscool
I tested your code.

It seems to be working.
Code: Select alllet pin = 1
let pinstatus = 1
po pin pinstatus

[home]
cls
if pinstatus == 0 then button "routerOFF.jpg" [toggle]
if pinstatus == 1 then button "routerON.jpg" [toggle]
if pinstatus == 0 then imagebutton "routerOFF.jpg" [toggle]
if pinstatus == 1 then imagebutton "routerON.jpg" [toggle]
wait

[toggle]
if pinstatus == 0 then pinstatus = 1 else pinstatus = 0
po pin pinstatus
goto [home]

Re: Imagebutton not branching.

PostPosted: Wed May 11, 2016 3:14 am
by Electroguard
Please retry below so we are definitely talking about the same thing, because it definitely is not working in my Alpha24- which I have reformatted and reflashed several times.

I've commented out the ordinary buttons to avoid any confusion, and added an 'end' into [toggle] so that if an imagebutton branched there it would be obvious because the program would toggle the blue led and then end with 'Done...' msg.
But for me it just keeps redrawing the same picture without ever branching to [toggle].

If you uncomment the ordinary buttons you will see that they DO branch to [toggle] as expected.


Code: Select alllet pin = 1
let pinstatus = 1
po pin pinstatus

[home]
cls
'if pinstatus == 0 then button "routerOFF.jpg" [toggle]
'if pinstatus == 1 then button "routerON.jpg" [toggle]
if pinstatus == 0 then imagebutton "routerOFF.jpg" [toggle]
if pinstatus == 1 then imagebutton "routerON.jpg" [toggle]
wait

[toggle]
if pinstatus == 0 then pinstatus = 1 else pinstatus = 0
po pin pinstatus
end
goto [home]