Page 1 of 1

Best Practice way to create array of buttons?

Posted: Mon Jun 13, 2016 5:25 pm
by octacon100
Hi All,

I've been wrestling over the weekend with creating a screen that moves or does actions based on buttons pressed, and I'm getting close to having it done, but in rare cases I'm seeing that more than one button reacts to a button being pushed. I'm trying to figure out why this could be the case. I've tried several ways to change the "action" part of the button code, but nothing seems to make a difference. Is there anything glaringly obviously wrong with this code?

screen lineButtonTest:

Code: Select all

    

def handleScreenClick():
        selectedButton.handleClick()

screen lineButtonTest:
    modal True
    zorder 10
    frame:
        style_group "evidenceOverloadStyle"
        xsize 3000
        ysize 2000

        #text str(testButton.buttonPos[0]) + "\n" + str(startPos[0])
        #text str(testButton.lineEndPos[0]) + "\n" + str(endPos[0])  xpos 100
        #text "[selectedAnswer]"

        add screenLineRender
        for item in buttonArray:
            if item.type == "Answer" and item.selected == True and item.animationShown == False:
                textbutton item.buttonText anchor (0.5, 0.5) style_group "evidenceOverloadStyleSelected" pos item.buttonPos action NullAction at movingDissolveButton(item.buttonPos, item.lineEndPos, item)
            textbutton item.buttonText anchor (0.5, 0.5) pos item.buttonPos action [SetVariable("selectedButton", item), handleScreenClick] at None

        at moveScreenAround(startPos, endPos)
I've tried a few different ways of doing the handleScreenClick method, like putting it inside a "Function" screen action, putting a hide(lineButtonTest) before the function and show("lineButtonTest") after the function, but I'm still seeing other buttons react like they were selected, and some code is running even though it shouldn't. Any advice on what I'm doing wrong would be much appreciated.