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(Ihandle *ih) {
char buf[MSG_BUFSIZE];
UNREFERENCED_PARAMETER(ih);
if (divertStart(IupGetAttribute(filterText, "VALUE"), buf) == 0) {
showStatus(buf);
return IUP_DEFAULT;
}
// successfully started
showStatus("Started 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(Ihandle *ih) {
int ix;
UNREFERENCED_PARAMETER(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]->processTriggered = 0; // use = here since is threads already stopped
IupSetAttribute(modules[ix]->iconHandle, "IMAGE", "none_icon");
}
sendState = SEND_STATUS_NONE;
IupSetAttribute(stateIcon, "IMAGE", "none_icon");
showStatus("Stopped. To begin again, edit criteria and click Start.");
return IUP_DEFAULT;
}
static int uiToggleControls(Ihandle *ih, int state) {
Ihandle *controls = (Ihandle*)IupGetAttribute(ih, CONTROLS_HANDLE);
short *target = (short*)IupGetAttribute(ih, SYNCED_VALUE);
int controlsActive = IupGetInt(controls, "ACTIVE");
if (controlsActive && !state) {
IupSetAttribute(controls, "ACTIVE", "NO");
InterlockedExchange16(target, I2S(state));
} else if (!controlsActive && state) {
IupSetAttribute(controls, "ACTIVE", "YES");
InterlockedExchange16(target, I2S(state));
}