I need a toggle button so when a key is pressed it starts then stops when the key is

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Charade
    New Member
    • Apr 2017
    • 1

    I need a toggle button so when a key is pressed it starts then stops when the key is

    I need this to start when PageUp is pressed then stop when PageUp is pressed again. or only start when PgUp is held down then when the key isn't pressed, it stops


    static int uiStartCb(Ihand le *ih) {
    char buf[MSG_BUFSIZE];
    UNREFERENCED_PA RAMETER(ih);
    if (divertStart(Iu pGetAttribute(f ilterText, "VALUE"), buf) == 0) {
    showStatus(buf) ;
    return IUP_DEFAULT;
    }

    // successfully started
    showStatus("Sta rted filtering. Enable functionalities to take effect. L");
    IupSetAttribute (filterText, "ACTIVE", "NO");
    IupSetAttribute (filterButton, "TITLE", "Stop");
    IupSetCallback( filterButton, "ACTION", uiStopCb);
    IupSetAttribute (timer, "RUN", "YES");
    }
    return IUP_DEFAULT;
    }

    static int uiStopCb(Ihandl e *ih) {
    int ix;
    UNREFERENCED_PA RAMETER(ih);

    // try stopping
    IupSetAttribute (filterButton, "ACTIVE", "NO");
    IupFlush(); // flush to show disabled state
    divertStop();

    IupSetAttribute (filterText, "ACTIVE", "YES");
    IupSetAttribute (filterButton, "TITLE", "Start");
    IupSetAttribute (filterButton, "ACTIVE", "YES");
    IupSetCallback( filterButton, "ACTION", uiStartCb);

    // stop timer and clean up icons
    IupSetAttribute (timer, "RUN", "NO");
    for (ix = 0; ix < MODULE_CNT; ++ix) {
    modules[ix]->processTrigger ed = 0; // use = here since is threads already stopped
    IupSetAttribute (modules[ix]->iconHandle, "IMAGE", "none_icon" );
    }
    sendState = SEND_STATUS_NON E;
    IupSetAttribute (stateIcon, "IMAGE", "none_icon" );

    showStatus("Sto pped. To begin again, edit criteria and click Start.");
    return IUP_DEFAULT;
    }

    static int uiToggleControl s(Ihandle *ih, int state) {
    Ihandle *controls = (Ihandle*)IupGe tAttribute(ih, CONTROLS_HANDLE );
    short *target = (short*)IupGetA ttribute(ih, SYNCED_VALUE);
    int controlsActive = IupGetInt(contr ols, "ACTIVE");
    if (controlsActive && !state) {
    IupSetAttribute (controls, "ACTIVE", "NO");
    InterlockedExch ange16(target, I2S(state));
    } else if (!controlsActiv e && state) {
    IupSetAttribute (controls, "ACTIVE", "YES");
    InterlockedExch ange16(target, I2S(state));
    }
Working...