diff options
author | Kim Ho <kho@redhat.com> | 2003-12-09 03:47:32 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-12-09 03:47:32 +0000 |
commit | bc67c73d4a212a1a0a58f1218907f88e4896adfb (patch) | |
tree | 0b6ff0be1eea2dcd15ec02ed2ae18a8760b5138f /libjava/gnu/java | |
parent | 7dd8177fc7f953488a096ef37329781fda227d4b (diff) | |
download | gcc-bc67c73d4a212a1a0a58f1218907f88e4896adfb.zip gcc-bc67c73d4a212a1a0a58f1218907f88e4896adfb.tar.gz gcc-bc67c73d4a212a1a0a58f1218907f88e4896adfb.tar.bz2 |
Fix for Checkbox states.
2003-12-08 Kim Ho <kho@redhat.com>
Fix for Checkbox states.
* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java:
(currentState): New field.
(nativeCreate): Add initial state parameter.
(create): Changed to reflect new parameter.
(setState): Fire only on changed states.
(postItemEvent): Fire only on changed states. Also change the
Java Checkbox to reflect new state.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c:
(nativeCreate): Add parameter and set active state.
From-SVN: r74459
Diffstat (limited to 'libjava/gnu/java')
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java index 67469c9..174a169 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java @@ -1,5 +1,5 @@ /* GtkCheckboxPeer.java -- Implements CheckboxPeer with GTK - Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,8 +48,11 @@ public class GtkCheckboxPeer extends GtkComponentPeer { // Group from last time it was set. public GtkCheckboxGroupPeer old_group; + // The current state of the GTK checkbox. + private boolean currentState; - public native void nativeCreate (GtkCheckboxGroupPeer group); + public native void nativeCreate (GtkCheckboxGroupPeer group, + boolean state); public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group); public native void connectHooks (); @@ -66,12 +69,14 @@ public class GtkCheckboxPeer extends GtkComponentPeer { CheckboxGroup g = ((Checkbox) awtComponent).getCheckboxGroup (); old_group = GtkCheckboxGroupPeer.getCheckboxGroupPeer (g); - nativeCreate (old_group); + currentState = ((Checkbox)awtComponent).getState(); + nativeCreate (old_group, currentState); } public void setState (boolean state) { - set ("active", state); + if (currentState != state) + set ("active", state); } public void setLabel (String label) @@ -103,7 +108,19 @@ public class GtkCheckboxPeer extends GtkComponentPeer // need information that we have. public void postItemEvent (Object item, int stateChange) { - super.postItemEvent (awtComponent, stateChange); + Checkbox currentCheckBox = ((Checkbox)awtComponent); + // A firing of the event is only desired if the state has changed due to a + // button press. The currentCheckBox's state must be different from the + // one that the stateChange is changing to. + // stateChange = 1 if it goes from false -> true + // stateChange = 2 if it goes from true -> false + if (( !currentCheckBox.getState() && stateChange == 1) + || (currentCheckBox.getState() && stateChange == 2)) + { + super.postItemEvent (awtComponent, stateChange); + currentState = !currentCheckBox.getState(); + currentCheckBox.setState(currentState); + } } public void dispose () |