pvbrowser manual
Back Content Forward

slot programming

Here you see the slots for a very simple usage of buttons and text labels. When clicking on "pushButton2" the number of clicks will be displayed on "textLabel1". When clicking on "pushButton1" mask1 will be called, because the program will return to the loop in "pvMain".

typedef struct // (todo: define your data structure here)
{
  int click; // number of clicks
}
DATA;

static int slotInit(PARAM *p, DATA *d)
{
  if(p == NULL || d == NULL) return -1;
  memset(d,0,sizeof(DATA));
  return 0;
}

static int slotButtonEvent(PARAM *p, int id, DATA *d)
{
  if(p == NULL || id == 0 || d == NULL) return -1;
  if(id == pushButton1)
  {
    return 1; // call mask 1
  }
  if(id == pushButton2)
  {
    pvPrintf(p,textLabel1,"click %d",d->click++);
  }

  return 0;
}

Back Content Forward