Example #1
0
/* this is called only for canvas */
void iupmotCanvasKeyReleaseEvent(Widget w, Ihandle *ih, XEvent *evt, Boolean *cont)
{
  if (motKeyDiscardKeypressRepeat(evt))
  {
    /* call key_press because it was removed from the queue */
    iupmotKeyPressEvent(w, ih, evt, cont);
  }
  else
  {
    int result;
    int code = iupmotKeyDecode((XKeyEvent*)evt);
    if (code == 0) 
      return;
    result = iupKeyCallKeyPressCb(ih, code, 0);
    if (result == IUP_CLOSE)
    {
      IupExitLoop();
      return;
    }
    if (result == IUP_IGNORE)
    {
      *cont = False;
      return;
    }
  }
}
Example #2
0
static void motTextKeyPressEvent(Widget w, Ihandle *ih, XKeyEvent *evt, Boolean *cont)
{
  Widget spinbox;

  *cont = True;
  iupmotKeyPressEvent(w, ih, (XEvent*)evt, cont);
  if (*cont == False)
    return;

  if (evt->state & ControlMask && !(state & Mod1Mask || state & Mod5Mask))   /* Ctrl but NOT Alt */
  {
    KeySym motcode = iupmotKeycodeToKeysym(evt);
    if (motcode == XK_c || motcode == XK_x || motcode == XK_v || motcode == XK_a)
    {
      ih->data->disable_callbacks = -1; /* let callbacks be processed in motTextSetClipboardAttrib */

      if (motcode == XK_c)
        motTextSetClipboardAttrib(ih, "COPY");
      else if (motcode == XK_x)
        motTextSetClipboardAttrib(ih, "CUT");
      else if (motcode == XK_v)
        motTextSetClipboardAttrib(ih, "PASTE");
      else if (motcode == XK_a)
        XmTextSetSelection(ih->handle, 0, XmTextGetLastPosition(ih->handle), CurrentTime);

      ih->data->disable_callbacks = 0;

      *cont = False; 
      return;
    }
  }

  spinbox = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (spinbox && XmIsSpinBox(spinbox))
  {
    KeySym motcode = iupmotKeycodeToKeysym(evt);
    if (motcode == XK_Left || motcode == XK_Right)
    {
      /* avoid spin increment using Left/Right arrows, 
         but must manually handle the new cursor position */
      XmTextPosition caret_pos = XmTextGetInsertionPosition(ih->handle);
      XmTextSetInsertionPosition(ih->handle, (motcode == XK_Left)? caret_pos-1: caret_pos+1);
      *cont = False; 
    }
  }
}
Example #3
0
static void motTextKeyPressEvent(Widget w, Ihandle *ih, XKeyEvent *evt, Boolean *cont)
{
  Widget spinbox;

  *cont = True;
  iupmotKeyPressEvent(w, ih, (XEvent*)evt, cont);
  if (*cont == False)
    return;

  if (evt->state & ControlMask)   /* Ctrl */
  {
    KeySym motcode = XKeycodeToKeysym(iupmot_display, evt->keycode, 0);
    if (motcode == XK_c)
      motTextSetClipboardAttrib(ih, "COPY");
    else if (motcode == XK_x)
      motTextSetClipboardAttrib(ih, "CUT");
    else if (motcode == XK_v)
      motTextSetClipboardAttrib(ih, "PASTE");
    else if (motcode == XK_a)
      XmTextSetSelection(ih->handle, 0, XmTextGetLastPosition(ih->handle), CurrentTime);
  }

  spinbox = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (spinbox && XmIsSpinBox(spinbox))
  {
    KeySym motcode = XKeycodeToKeysym(iupmot_display, evt->keycode, 0);
    if (motcode == XK_Left || motcode == XK_Right)
    {
      /* avoid spin increment using Left/Right arrows, 
         but must manually handle the new cursor position */
      XmTextPosition caret_pos = XmTextGetInsertionPosition(ih->handle);
      XmTextSetInsertionPosition(ih->handle, (motcode == XK_Left)? caret_pos-1: caret_pos+1);
      *cont = False; 
    }
  }
}
Example #4
0
static void motListEditKeyPressEvent(Widget cbedit, Ihandle *ih, XKeyEvent *evt, Boolean *cont)
{
  *cont = True;
  iupmotKeyPressEvent(cbedit, ih, (XEvent*)evt, cont);
  if (*cont == False)
    return;

  if (evt->state & ControlMask)   /* Ctrl */
  {
    KeySym motcode = iupmotKeycodeToKeysym(evt);
    if (motcode == XK_c)
    {
      motListSetClipboardAttrib(ih, "COPY");
      *cont = False;
      return;
    }
    else if (motcode == XK_x)
    {
      motListSetClipboardAttrib(ih, "CUT");
      *cont = False;
      return;
    }
    else if (motcode == XK_v)
    {
      motListSetClipboardAttrib(ih, "PASTE");
      *cont = False;
      return;
    }
    else if (motcode == XK_a)
    {
      XmTextFieldSetSelection(cbedit, 0, XmTextFieldGetLastPosition(cbedit), CurrentTime);
      *cont = False;
      return;
    }
  }
}
Example #5
0
static void motValKeyPressEvent(Widget w, Ihandle *ih, XKeyEvent *evt, Boolean *cont)
{
  KeySym motcode;

  *cont = True;
  iupmotKeyPressEvent(w, ih, (XEvent*)evt, cont);
  if (*cont == False)
    return;

  motcode = XKeycodeToKeysym(iupmot_display, evt->keycode, 0);

  /* add missing support for numeric keyboard */
  /* add missing support for left/right in vertical
    and up/down in horizontal */
  if (motcode == XK_Left || motcode == XK_KP_Left || 
      motcode == XK_Up || motcode == XK_KP_Up)
  {
    motValIncLineValue(ih, -1);
    *cont = False;
    return;
  }
  if (motcode == XK_Right || motcode == XK_KP_Right || 
      motcode == XK_Down || motcode == XK_KP_Down)
  {
    motValIncLineValue(ih, 1);
    *cont = False;
    return;
  }
  if (motcode == XK_Prior || motcode == XK_KP_Page_Up)
  {
    motValIncPageValue(ih, -1);
    *cont = False;
    return;
  }
  if (motcode == XK_Next || motcode == XK_KP_Page_Down)
  {
    motValIncPageValue(ih, 1);
    *cont = False;
    return;
  }

  /* change Home and End default behaviour */
  if (ih->data->inverted)
  {
    if (motcode==XK_Home || motcode==XK_KP_Home)
    {
      int ival = SHRT_MAX;  /* set to maximum */
      XtVaSetValues(ih->handle, XmNvalue, ival, NULL);
      motValCallAction(ih, ival, 1);
      *cont = False;
      return;
    }
    if (motcode==XK_End || motcode==XK_KP_End)
    {
      int ival = 0; /* set to minimum */
      XtVaSetValues(ih->handle, XmNvalue, ival, NULL);
      motValCallAction(ih, ival, 1);
      *cont = False;
      return;
    }
  }
  else
  {
    /* add missing support for numeric keyboard */
    if (motcode==XK_KP_Home)
    {
      int ival = 0; /* set to minimum */
      XtVaSetValues(ih->handle, XmNvalue, ival, NULL);
      motValCallAction(ih, ival, 1);
      *cont = False;
      return;
    }
    if (motcode==XK_KP_End)
    {
      int ival = SHRT_MAX;  /* set to maximum */
      XtVaSetValues(ih->handle, XmNvalue, ival, NULL);
      motValCallAction(ih, ival, 1);
      *cont = False;
      return;
    }
  }
}