示例#1
0
 void hookEvents() {
   super.hookEvents();
   OS.g_signal_connect_closure(handle, OS.activate, display.closures[ACTIVATE], false);
   OS.g_signal_connect_closure(handle, OS.activate, display.closures[ACTIVATE_INVERSE], true);
   OS.g_signal_connect_closure_by_id(
       handle,
       display.signalIds[BUTTON_PRESS_EVENT],
       0,
       display.closures[BUTTON_PRESS_EVENT],
       false);
   OS.g_signal_connect_closure_by_id(
       handle, display.signalIds[FOCUS_OUT_EVENT], 0, display.closures[FOCUS_OUT_EVENT], false);
   OS.g_signal_connect_closure(
       clientHandle, OS.size_allocate, display.closures[SIZE_ALLOCATE], true);
   OS.g_signal_connect_closure_by_id(
       handle,
       display.signalIds[ENTER_NOTIFY_EVENT],
       0,
       display.closures[ENTER_NOTIFY_EVENT],
       false);
 }
示例#2
0
  void hookEvents() {
    super.hookEvents();
    if ((style & SWT.SEPARATOR) != 0) return;
    OS.g_signal_connect_closure(handle, OS.clicked, display.closures[CLICKED], false);
    /*
     * Feature in GTK. GtkToolItem does not respond to basic listeners
     * such as button-press, enter-notify to it. The fix is to assign
     * the listener to child (GtkButton) of the tool-item.
     */
    eventHandle = OS.gtk_bin_get_child(handle);
    if ((style & SWT.DROP_DOWN) != 0 && OS.GTK_VERSION >= OS.VERSION(2, 6, 0)) {
      long /*int*/ list = OS.gtk_container_get_children(eventHandle);
      eventHandle = OS.g_list_nth_data(list, 0);
      if (arrowHandle != 0)
        OS.g_signal_connect_closure(arrowHandle, OS.clicked, display.closures[CLICKED], false);
    }
    OS.g_signal_connect_closure(
        handle, OS.create_menu_proxy, display.closures[CREATE_MENU_PROXY], false);

    OS.g_signal_connect_closure_by_id(
        eventHandle,
        display.signalIds[ENTER_NOTIFY_EVENT],
        0,
        display.closures[ENTER_NOTIFY_EVENT],
        false);
    OS.g_signal_connect_closure_by_id(
        eventHandle,
        display.signalIds[LEAVE_NOTIFY_EVENT],
        0,
        display.closures[LEAVE_NOTIFY_EVENT],
        false);
    OS.g_signal_connect_closure_by_id(
        eventHandle, display.signalIds[FOCUS_IN_EVENT], 0, display.closures[FOCUS_IN_EVENT], false);
    OS.g_signal_connect_closure_by_id(
        eventHandle,
        display.signalIds[FOCUS_OUT_EVENT],
        0,
        display.closures[FOCUS_OUT_EVENT],
        false);
    /*
     * Feature in GTK.  Usually, GTK widgets propagate all events to their
     * parent when they are done their own processing.  However, in contrast
     * to other widgets, the buttons that make up the tool items, do not propagate
     * the mouse up/down events. It is interesting to note that they DO propagate
     * mouse motion events.  The fix is to explicitly forward mouse up/down events
     * to the parent.
     */
    int mask =
        OS.GDK_EXPOSURE_MASK
            | OS.GDK_POINTER_MOTION_MASK
            | OS.GDK_BUTTON_PRESS_MASK
            | OS.GDK_BUTTON_RELEASE_MASK
            | OS.GDK_ENTER_NOTIFY_MASK
            | OS.GDK_LEAVE_NOTIFY_MASK
            | OS.GDK_KEY_PRESS_MASK
            | OS.GDK_KEY_RELEASE_MASK
            | OS.GDK_FOCUS_CHANGE_MASK;
    OS.gtk_widget_add_events(eventHandle, mask);
    OS.g_signal_connect_closure_by_id(
        eventHandle,
        display.signalIds[BUTTON_PRESS_EVENT],
        0,
        display.closures[BUTTON_PRESS_EVENT],
        false);
    OS.g_signal_connect_closure_by_id(
        eventHandle,
        display.signalIds[BUTTON_RELEASE_EVENT],
        0,
        display.closures[BUTTON_RELEASE_EVENT],
        false);
    OS.g_signal_connect_closure_by_id(
        eventHandle, display.signalIds[EVENT_AFTER], 0, display.closures[EVENT_AFTER], false);

    long /*int*/ topHandle = topHandle();
    OS.g_signal_connect_closure_by_id(
        topHandle, display.signalIds[MAP], 0, display.closures[MAP], true);
  }