Home AMX User Forum AMXForums Archive Threads Tips and Tricks

Disable button upon activation off another button ?

Hi

I have a situation where I need to make a button inactiv (grayed out), when i toogle another button.

The situation is that I have two buttons, one for activation of a function and another button for another function.
the second button toggles and alarm installation on and off. Whenever the alarm installation is on, I must secure that button one is not activated....

How is this done the easiest way ?

Comments

  • ericmedleyericmedley Posts: 4,177
    bia@jdm.dk wrote: »
    Hi

    I have a situation where I need to make a button inactiv (grayed out), when i toogle another button.

    The situation is that I have two buttons, one for activation of a function and another button for another function.
    the second button toggles and alarm installation on and off. Whenever the alarm installation is on, I must secure that button one is not activated....

    How is this done the easiest way ?

    I would set a flag in code for the 'button active/inactive' state. Then use the TP commands to set the opacity of the other button depending upon the state.
  • DHawthorneDHawthorne Posts: 4,584
    If I have to do something like that, I make the button a multi-state bargraph with on, off and disabled states that are visually unique. In my feedback routine, I send it the appropriate level (which in this case would be determined by a flag set by the other button). I'm pretty sure there is a send-command to disable a button, but I wouldn't bother ... I'd trap the same flag in the button event and just ignore it if the flag is set. Likewise, I wouldn't bother changing the button colors or opacity in code; to my way of thinking, just creating a separate state for it is easier. It also has the advantage of being compatible with palette changes.
  • There was a similar requirement in one of our projects lately: the user should be able to alter some settings of the program using a special 'config-mode'. By pressing the config button (id 262) there should appear two other buttons OK and CANCEL (263,264) to confirm / reject the changed settings.

    Here's the code we used. Maybe you can use some parts of it.
    Patrick
    //... global variables...
    volatile integer hctc_EditConfig = 0
    volatile integer HCTCOKCANCEL[] = { 263, 264 }
    //...
    BUTTON_EVENT[dvTP_Modes,262]    // edit config --> PW required (setup on panel)
    {
        PUSH:
        {
            // local variables
            STACK_VAR INTEGER iPanelIndex
    
            // get the active panel index
            iPanelIndex = GET_LAST(dvTP_Modes)
    
            // set the panel edit mode, but only if no other panel is in edit mode
            if (!hctc_EditConfig)
            {
                hctc_EditConfig = iPanelIndex
    
                SEND_COMMAND BUTTON.INPUT.DEVICE, "'ABEEP'"
                SEND_COMMAND BUTTON.INPUT.DEVICE, "'^SHO-263.264,1'" 
                SEND_COMMAND BUTTON.INPUT.DEVICE, "'^ENA-263.264,1'" 
            }
        }
        RELEASE:
        {
        }    
    }
    BUTTON_EVENT[dvTP_Modes,HCTCOKCANCEL]    // save/cancel config --> PW required
    {
        PUSH:
        {
        }
        HOLD[10]:
        {
            // local variables
            STACK_VAR INTEGER iPanelIndex
            STACK_VAR INTEGER iButtonIndex
    
            // get the active panel and button index
            iPanelIndex = GET_LAST(dvTP_Modes)
            iButtonIndex = GET_LAST(HCTCOKCANCEL)
    
            // if edit mode for active panel is set --> save/cancel config
            if (iPanelIndex == hctc_EditConfig)
            {
                SEND_COMMAND BUTTON.INPUT.DEVICE, "'ABEEP'"
                if (iButtonIndex == 1)
                {
                if (hclp_SaveModes(hctcModes))
                    SEND_COMMAND BUTTON.INPUT.DEVICE, "'ABEEP'"  // ...do something usefull here
                else
                    SEND_COMMAND BUTTON.INPUT.DEVICE, "'ADBEEP'"  // ...do something usefull here
                }
                {
                SEND_COMMAND BUTTON.INPUT.DEVICE, "'^SHO-263.264,0'" 
                SEND_COMMAND BUTTON.INPUT.DEVICE, "'^ENA-263.264,0'" 
                hctc_EditConfig = FALSE
                }
            }
        }
    }
    
  • I do this type of thing with tracking flags. What I have done in the pass is to pop another button up overtop of the button to prevent it from being accessable by the client. With TP4 you can set this pop up button opacity level.
  • viningvining Posts: 4,368
    The last one I did similar to this was for the DSP portion of my Auto Patch module. Depending the the config file I send at start up determines if I'm controlling 1, 2 or 3 18x18 PrecisLT's.

    Normally I would just use the ^SHO command to hide the buttons that weren't necassary but if I was only controlling 1 or 2 devices my GUI page looked lop sided. So in this case I decided to created greyed out button or button with maybe the opacity of 100 on the 1-225 scale that had no channel number assigned at all. Just dead buttons with no functions. On top of them I put the real buttons with channel numbers assigned and the regular on & off states for feedback. Now when the config file is sent at start up the buttons that aren't needed disappear by use of the ^SHO command and reveal the dummy buttons beneath. If I recall if a button that has no opcaity at all it is affectively not there and button pushes on it won't work.

    In this situation I felt it was easier to do this then tracking flags and using multi_state bargraphs since I had 54 button (zones) to contend with but otherwise I do like the send_levels to bargraphs approach.
Sign In or Register to comment.