@Override
 long /*int*/ gtk_key_press_event(long /*int*/ widget, long /*int*/ eventPtr) {
   long /*int*/ result = super.gtk_key_press_event(widget, eventPtr);
   if (result != 0) return result;
   if (focusIndex == -1) return result;
   GdkEventKey gdkEvent = new GdkEventKey();
   OS.memmove(gdkEvent, eventPtr, GdkEventKey.sizeof);
   switch (gdkEvent.keyval) {
     case OS.GDK_Return:
     case OS.GDK_KP_Enter:
     case OS.GDK_space:
       Event event = new Event();
       event.text = ids[focusIndex];
       sendSelectionEvent(SWT.Selection, event, true);
       break;
     case OS.GDK_Tab:
       if (focusIndex < offsets.length - 1) {
         focusIndex++;
         redraw();
       }
       break;
     case OS.GDK_ISO_Left_Tab:
       if (focusIndex > 0) {
         focusIndex--;
         redraw();
       }
       break;
   }
   return result;
 }
Exemple #2
0
 LRESULT wmNotifyChild(NMHDR hdr, int /*long*/ wParam, int /*long*/ lParam) {
   if (OS.COMCTL32_MAJOR >= 6) {
     switch (hdr.code) {
       case OS.NM_RETURN:
       case OS.NM_CLICK:
         NMLINK item = new NMLINK();
         OS.MoveMemory(item, lParam, NMLINK.sizeof);
         Event event = new Event();
         event.text = ids[item.iLink];
         sendSelectionEvent(SWT.Selection, event, true);
         break;
     }
   }
   return super.wmNotifyChild(hdr, wParam, lParam);
 }
Exemple #3
0
 LRESULT WM_CHAR(int /*long*/ wParam, int /*long*/ lParam) {
   LRESULT result = super.WM_CHAR(wParam, lParam);
   if (result != null) return result;
   if (OS.COMCTL32_MAJOR < 6) {
     if (focusIndex == -1) return result;
     switch ((int) /*64*/ wParam) {
       case ' ':
       case SWT.CR:
         Event event = new Event();
         event.text = ids[focusIndex];
         sendSelectionEvent(SWT.Selection, event, true);
         break;
       case SWT.TAB:
         boolean next = OS.GetKeyState(OS.VK_SHIFT) >= 0;
         if (next) {
           if (focusIndex < offsets.length - 1) {
             focusIndex++;
             redraw();
           }
         } else {
           if (focusIndex > 0) {
             focusIndex--;
             redraw();
           }
         }
         break;
     }
   } else {
     switch ((int) /*64*/ wParam) {
       case ' ':
       case SWT.CR:
       case SWT.TAB:
         /*
          * NOTE: Call the window proc with WM_KEYDOWN rather than WM_CHAR
          * so that the key that was ignored during WM_KEYDOWN is processed.
          * This allows the application to cancel an operation that is normally
          * performed in WM_KEYDOWN from WM_CHAR.
          */
         int /*long*/ code = callWindowProc(handle, OS.WM_KEYDOWN, wParam, lParam);
         return new LRESULT(code);
     }
   }
   return result;
 }
Exemple #4
0
 LRESULT WM_LBUTTONUP(int /*long*/ wParam, int /*long*/ lParam) {
   LRESULT result = super.WM_LBUTTONUP(wParam, lParam);
   if (result == LRESULT.ZERO) return result;
   if (OS.COMCTL32_MAJOR < 6) {
     if (mouseDownIndex == -1) return result;
     int x = OS.GET_X_LPARAM(lParam);
     int y = OS.GET_Y_LPARAM(lParam);
     Rectangle[] rects = getRectangles(mouseDownIndex);
     for (int i = 0; i < rects.length; i++) {
       Rectangle rect = rects[i];
       if (rect.contains(x, y)) {
         Event event = new Event();
         event.text = ids[mouseDownIndex];
         sendSelectionEvent(SWT.Selection, event, true);
         break;
       }
     }
   }
   mouseDownIndex = -1;
   return result;
 }
 @Override
 long /*int*/ gtk_button_release_event(long /*int*/ widget, long /*int*/ event) {
   long /*int*/ result = super.gtk_button_release_event(widget, event);
   if (result != 0) return result;
   if (focusIndex == -1) return result;
   GdkEventButton gdkEvent = new GdkEventButton();
   OS.memmove(gdkEvent, event, GdkEventButton.sizeof);
   if (gdkEvent.button == 1) {
     int x = (int) gdkEvent.x;
     int y = (int) gdkEvent.y;
     if ((style & SWT.MIRRORED) != 0) x = getClientWidth() - x;
     Rectangle[] rects = getRectangles(focusIndex);
     for (int i = 0; i < rects.length; i++) {
       Rectangle rect = rects[i];
       if (rect.contains(x, y)) {
         Event ev = new Event();
         ev.text = ids[focusIndex];
         sendSelectionEvent(SWT.Selection, ev, true);
         return result;
       }
     }
   }
   return result;
 }