Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe2009-06-19 15:59:39 -0400
committerBogdan Gheorghe2009-06-19 15:59:39 -0400
commitf0e65558e26ed14400a3826af023a033b76d0c9d (patch)
tree0146868d98b2f11659ca43a255fff7c021e18b09
parent41e9bf92f50f9eceeb603774397c1ee8c5b56310 (diff)
downloadeclipse.platform.swt-R3_4_maintenance_patches.tar.gz
eclipse.platform.swt-R3_4_maintenance_patches.tar.xz
eclipse.platform.swt-R3_4_maintenance_patches.zip
273850 SWT.MouseDown event not fired on combo widget arrow down (GTK only)R3_4_maintenance_patches
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java46
1 files changed, 43 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index 029149cc62..50f27bc71f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -56,12 +56,12 @@ import org.eclipse.swt.events.*;
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
*/
public class Combo extends Composite {
- int /*long*/ buttonHandle, entryHandle, listHandle, textRenderer, cellHandle, popupHandle;
+ int /*long*/ buttonHandle, entryHandle, listHandle, textRenderer, cellHandle, popupHandle, menuHandle;
int lastEventTime, visibleCount = 5;
int /*long*/ gdkEventKey = 0;
int fixStart = -1, fixEnd = -1;
String [] items = new String [0];
- boolean ignoreSelect, lockText;
+ boolean ignoreSelect, lockText, selectionAdded;
static final int INNER_BORDER = 2;
@@ -460,6 +460,15 @@ void createHandle (int index) {
OS.gtk_cell_layout_set_attributes (handle, textRenderer, OS.text, 0, 0);
/*
+ * Feature in GTK. Toggle button creation differs between GTK versions. The
+ * fix is to call size_request() to force the creation of the button
+ * for those versions of GTK that defer the creation.
+ */
+ if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
+ OS.gtk_widget_size_request(handle, new GtkRequisition());
+ }
+ if (popupHandle != 0) findMenuHandle ();
+ /*
* Feature in GTK. There is no API to query the button
* handle from a combo box although it is possible to get the
* text field. The button handle is needed to hook events. The
@@ -564,6 +573,7 @@ void deregister () {
if (buttonHandle != 0) display.removeWidget (buttonHandle);
if (entryHandle != 0) display.removeWidget (entryHandle);
if (listHandle != 0) display.removeWidget (listHandle);
+ if (menuHandle != 0) display.removeWidget (menuHandle);
int /*long*/ imContext = imContext ();
if (imContext != 0) display.removeWidget (imContext);
}
@@ -610,6 +620,23 @@ int /*long*/ findPopupHandle (int /*long*/ oldList) {
return hdl;
}
+void findMenuHandle() {
+ OS.gtk_container_forall (popupHandle, display.allChildrenProc, 0);
+ if (display.allChildren != 0) {
+ int /*long*/ list = display.allChildren;
+ while (list != 0) {
+ int /*long*/ widget = OS.g_list_data (list);
+ if (OS.G_OBJECT_TYPE (widget) == OS.GTK_TYPE_MENU ()) {
+ menuHandle = widget;
+ break;
+ }
+ list = OS.g_list_next (list);
+ }
+ OS.g_list_free (display.allChildren);
+ display.allChildren = 0;
+ }
+}
+
void fixModal (int /*long*/ group, int /*long*/ modalGroup) {
if (popupHandle != 0) {
if (group != 0) {
@@ -677,7 +704,7 @@ void hookEvents () {
}
int eventMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK |
OS.GDK_BUTTON_RELEASE_MASK;
- int /*long*/ [] handles = new int /*long*/ [] {buttonHandle, entryHandle, listHandle};
+ int /*long*/ [] handles = new int /*long*/ [] {buttonHandle, entryHandle, listHandle, menuHandle};
for (int i=0; i<handles.length; i++) {
int /*long*/ eventHandle = handles [i];
if (eventHandle != 0) {
@@ -1271,6 +1298,18 @@ int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent) {
OS.memmove (event, gdkEvent, GdkEvent.sizeof);
switch (event.type) {
case OS.GDK_BUTTON_PRESS: {
+ if (OS.GTK_VERSION < OS.VERSION (2, 8, 0) && !selectionAdded) {
+ int /*long*/ grabHandle = OS.gtk_grab_get_current ();
+ if (grabHandle != 0) {
+ if (OS.G_OBJECT_TYPE (grabHandle) == OS.GTK_TYPE_MENU ()) {
+ menuHandle = grabHandle;
+ OS.g_signal_connect_closure_by_id (menuHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT], false);
+ OS.g_signal_connect_closure_by_id (menuHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT_INVERSE], true);
+ display.addWidget (menuHandle, this);
+ selectionAdded = true;
+ }
+ }
+ }
GdkEventButton gdkEventButton = new GdkEventButton ();
OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
if (gdkEventButton.button == 1) {
@@ -1512,6 +1551,7 @@ void register () {
if (buttonHandle != 0) display.addWidget (buttonHandle, this);
if (entryHandle != 0) display.addWidget (entryHandle, this);
if (listHandle != 0) display.addWidget (listHandle, this);
+ if (menuHandle != 0) display.addWidget (menuHandle, this);
int /*long*/ imContext = imContext ();
if (imContext != 0) display.addWidget (imContext, this);
}

Back to the top