Exemplo n.º 1
0
static int PreviousField(lua_State *L)
{
  Ihandle *h1 = iuplua_checkihandle(L,1);
  Ihandle *h2 = IupNextField(h1);
  iuplua_pushihandle(L,h2);
  return 1;
}
Exemplo n.º 2
0
static void iDialogAfterShow(Ihandle* ih)
{
  Ihandle* old_focus;
  IFni show_cb;
  int show_state;

  /* process all pending messages */
  IupFlush();

  old_focus = IupGetFocus();
  show_state = ih->data->show_state;

  show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
  if (show_cb && show_cb(ih, show_state) == IUP_CLOSE)
  {
    IupExitLoop();
    return;
  }

  if (show_state == IUP_SHOW)
  {
    if (show_cb)
      IupFlush();  /* again to update focus */

    /* do it only if show_cb did NOT changed the current focus */
    if (old_focus == IupGetFocus())
    {
      Ihandle *startfocus = IupGetAttributeHandle(ih, "STARTFOCUS");
      if (startfocus)
        IupSetFocus(startfocus);
      else
        IupNextField(ih);
    }
  }
}
Exemplo n.º 3
0
static void iDialogCallShowCb(Ihandle* ih)
{
  IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
  if (show_cb && show_cb(ih, ih->data->show_state) == IUP_CLOSE)
    IupExitLoop();

  if (ih->data->show_state == IUP_SHOW)
  {
    Ihandle *startfocus = IupGetAttributeHandle(ih, "STARTFOCUS");
    if (startfocus)
      IupSetFocus(startfocus);
    else
      IupNextField(ih);
  }
}
Exemplo n.º 4
0
Arquivo: iup_key.c Projeto: defdef/iup
int iupKeyProcessNavigation(Ihandle* ih, int code, int shift)
{
  /* this is called after K_ANY is processed, 
     so the user may change its behavior */

  if (code == K_cTAB)
  {
    int is_multiline = iupAttribGetInt(ih, "_IUP_MULTILINE_TEXT");
    if (is_multiline)
    {
      if (shift)
        IupPreviousField(ih);
      else
        IupNextField(ih);
      return 1;
    }
  }
  else if (code == K_TAB || code == K_sTAB)
  {
    int is_multiline = iupAttribGetInt(ih, "_IUP_MULTILINE_TEXT");
    if (!is_multiline)
    {
      if (code == K_sTAB || shift)
        IupPreviousField(ih);
      else
        IupNextField(ih);
      return 1;
    }
  }
  else if (code == K_UP || code == K_DOWN)
  {
    int is_button = (IupClassMatch(ih, "button") || 
                     IupClassMatch(ih, "toggle"));
    if (is_button)
    {
      if (code == K_UP)
        iupFocusPrevious(ih);
      else
        iupFocusNext(ih);
      return 1;
    }
  }
  else if (code==K_ESC)
  {
    Ihandle* bt = IupGetAttributeHandle(IupGetDialog(ih), "DEFAULTESC");
    if (iupObjectCheck(bt) && IupClassMatch(bt, "button"))
      iupdrvActivate(bt);
    return 1;
  }
  else if (code==K_CR || code==K_cCR)
  {
    int is_multiline = iupAttribGetInt(ih, "_IUP_MULTILINE_TEXT");
    if ((code==K_CR && !is_multiline) || (code==K_cCR && is_multiline))
    {
      Ihandle* bt = IupGetAttributeHandle(IupGetDialog(ih), "DEFAULTENTER");
      if (iupObjectCheck(bt) && IupClassMatch(bt, "button"))
        iupdrvActivate(bt);
      return 1;
    }
  }

  return 0;
}
Exemplo n.º 5
0
int iupKeyProcessNavigation(Ihandle* ih, int key, int shift)
{
  /* this is called after K_ANY is processed, 
     so the user may change its behavior */

  if (key == K_cTAB)
  {
    int is_multiline = (iupStrEqual(ih->iclass->name, "multiline") || 
                        (iupStrEqual(ih->iclass->name, "text") && IupGetInt(ih, "MULTILINE")));
    if (is_multiline)
    {
      if (shift)
        IupPreviousField(ih);
      else
        IupNextField(ih);
      return 0;   /* abort default processing */
    }
  }
  else if (key == K_TAB || key == K_sTAB)
  {
    int is_multiline = (iupStrEqual(ih->iclass->name, "multiline") || 
                        (iupStrEqual(ih->iclass->name, "text") && IupGetInt(ih, "MULTILINE")));
    if (!is_multiline)
    {
      if (key == K_sTAB)
        IupPreviousField(ih);
      else
        IupNextField(ih);
      return 0;   /* abort default processing */
    }
  }
  else if (key == K_UP || key == K_DOWN)
  {
    int is_button = (iupStrEqual(ih->iclass->name, "button") || 
                     iupStrEqual(ih->iclass->name, "toggle"));
    if (is_button)
    {
      if (key == K_UP)
        iupFocusPrevious(ih);
      else
        iupFocusNext(ih);
      return 0;   /* abort default processing */
    }
  }
  else if (key==K_ESC)
  {
    Ihandle* bt = IupGetAttributeHandle(IupGetDialog(ih), "DEFAULTESC");
    if (iupObjectCheck(bt) && iupStrEqual(bt->iclass->name, "button"))
      iupdrvActivate(bt);
    return 0;   /* abort default processing */
  }
  else if (key==K_CR || key==K_cCR)
  {
    int is_multiline = (iupStrEqual(ih->iclass->name, "multiline") || 
                        (iupStrEqual(ih->iclass->name, "text") && IupGetInt(ih, "MULTILINE")));

    if ((key==K_CR && !is_multiline) || (key==K_cCR && is_multiline))
    {
      Ihandle* bt = IupGetAttributeHandle(IupGetDialog(ih), "DEFAULTENTER");
      if (iupObjectCheck(bt) && iupStrEqual(bt->iclass->name, "button"))
        iupdrvActivate(bt);
      return 0;   /* abort default processing */
    }
  }

  return 1;
}
Exemplo n.º 6
0
static void NextField(void)
{
  iuplua_pushihandle(IupNextField(iuplua_checkihandle(1)));
}