Author: sanel.z
Date: 2007-07-13 06:25:31 -0700 (Fri, 13 Jul 2007)
New Revision: 5924
Log:
Applied patch from Tobias Markmann (thanks !); str #1733.
Modified:
trunk/fltk/RadioItem.h
trunk/fltk/ToggleItem.h
trunk/src/Item.cxx
Modified: trunk/fltk/RadioItem.h
===================================================================
--- trunk/fltk/RadioItem.h 2007-07-03 20:46:33 UTC (rev 5923)
+++ trunk/fltk/RadioItem.h 2007-07-13 13:25:31 UTC (rev 5924)
@@ -28,7 +28,7 @@
namespace fltk {
/** This widget makes a radio item in a popup or pulldown Menu.
- It's behavior in a Browser or other group is undefined. */
+ It's behavior in a Browser or MultiBrowser is that it changes its status
on multiple clicks (e.g. double click). */
class RadioItem : public Item {
public:
RadioItem(const char* label = 0) : Item(label) {type(RADIO);}
Modified: trunk/fltk/ToggleItem.h
===================================================================
--- trunk/fltk/ToggleItem.h 2007-07-03 20:46:33 UTC (rev 5923)
+++ trunk/fltk/ToggleItem.h 2007-07-13 13:25:31 UTC (rev 5924)
@@ -28,7 +28,7 @@
namespace fltk {
/** This widget makes a checkmark in a popup or pulldown Menu.
- It's behavior in a Browser or other group is undefined. */
+ It's behavior in a Browser or MultiBrowser is that it changes its status
on multiple clicks (e.g. double click). */
class ToggleItem : public Item {
public:
ToggleItem(const char* label = 0) : Item(label) {type(TOGGLE);}
Modified: trunk/src/Item.cxx
===================================================================
--- trunk/src/Item.cxx 2007-07-03 20:46:33 UTC (rev 5923)
+++ trunk/src/Item.cxx 2007-07-13 13:25:31 UTC (rev 5924)
@@ -22,9 +22,11 @@
//
#include <fltk/Item.h>
+#include <fltk/Group.h>
#include <fltk/Box.h>
#include <fltk/CheckButton.h>
#include <fltk/draw.h>
+#include <fltk/events.h>
#include <string.h>
using namespace fltk;
@@ -187,7 +189,20 @@
/** Returns 0 always. Items do not accept \e any events. Any results
of clicking on them is handled by the parent Menu or Browser. */
-int Item::handle(int) {return 0;}
+int Item::handle(int e) {
+ if (type() == TOGGLE) {
+ if (e == PUSH && event_clicks() > 0) state(!state());
+ } else if (type() == RADIO) {
+ if (e == PUSH && event_clicks() > 0) {
+ state(true);
+ Group *g = parent();
+ for (int n = 0; n < g->children(); n++) {
+ if (g->child(n) != this) g->child(n)->state(false);
+ }
+ }
+ }
+ return 0;
+}
////////////////////////////////////////////////////////////////
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit