summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2008-02-20 17:59:13 +0000
committerMatthias Melcher <fltk@matthiasm.com>2008-02-20 17:59:13 +0000
commitdc0ab1d06c3db76e8c1fd311b95abee40808864b (patch)
treec8a6d4485b7bfce9fe0aedd5ad2eea6b8098d90b
parent97c408f1d26106b50f8958e29bda160572012bba (diff)
STR 1719: fixed inconsistencies with FL_WHEN_NOT_CHANGED
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@6031 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES1
-rw-r--r--FL/Fl_Input_Choice.H38
-rw-r--r--src/Fl_Button.cxx4
-rw-r--r--src/Fl_Input.cxx7
-rw-r--r--src/Fl_Input_.cxx4
5 files changed, 43 insertions, 11 deletions
diff --git a/CHANGES b/CHANGES
index 9d546500f..ac8f1a318 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,7 @@ CHANGES IN FLTK 1.1.8
STR #1742, STR #1777, STR #1794, STR #1827, STR #1843,
STR #1796, STR #1815, STR #1726, STR #1753, STR #1855,
STR #1862, STR #1867, STR #1874)
+ - Fixed inconsistencies with CHANGED flags (STR #1719)
- Fixed message sent to hidden widgets (STR #1849)
- Fixed width calculation in Fl_Help_ViewA (STR #1868)
- Fixed offset bug in OS X pixmap code (STR #1856)
diff --git a/FL/Fl_Input_Choice.H b/FL/Fl_Input_Choice.H
index cf7f8e54c..3c2c22f96 100644
--- a/FL/Fl_Input_Choice.H
+++ b/FL/Fl_Input_Choice.H
@@ -38,6 +38,7 @@
#include <FL/Fl_Input.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/fl_draw.H>
+#include <string.h>
class Fl_Input_Choice : public Fl_Group {
// Private class to handle slightly 'special' behavior of menu button
@@ -60,19 +61,41 @@ class Fl_Input_Choice : public Fl_Group {
static void menu_cb(Fl_Widget*, void *data) {
Fl_Input_Choice *o=(Fl_Input_Choice *)data;
const Fl_Menu_Item *item = o->menubutton()->mvalue();
- if ( item && item->flags & (FL_SUBMENU|FL_SUBMENU_POINTER) ) return; // ignore submenus
- o->inp_->value(o->menu_->text());
- o->inp_->set_changed();
- o->do_callback();
+ if (item && item->flags & (FL_SUBMENU|FL_SUBMENU_POINTER)) return; // ignore submenus
+ if (!strcmp(o->inp_->value(), o->menu_->text()))
+ {
+ o->Fl_Widget::clear_changed();
+ if (o->when() & FL_WHEN_NOT_CHANGED)
+ o->do_callback();
+ }
+ else
+ {
+ o->inp_->value(o->menu_->text());
+ o->inp_->set_changed();
+ o->Fl_Widget::set_changed();
+ if (o->when() & (FL_WHEN_CHANGED|FL_WHEN_RELEASE))
+ o->do_callback();
+ }
+
+ if (o->callback() != default_callback)
+ {
+ o->Fl_Widget::clear_changed();
+ o->inp_->clear_changed();
+ }
}
static void inp_cb(Fl_Widget*, void *data) {
Fl_Input_Choice *o=(Fl_Input_Choice *)data;
- if (o->inp_->changed())
+ if (o->inp_->changed()) {
o->Fl_Widget::set_changed();
- else
+ if (o->when() & (FL_WHEN_CHANGED|FL_WHEN_RELEASE))
+ o->do_callback();
+ } else {
o->Fl_Widget::clear_changed();
- o->do_callback();
+ if (o->when() & FL_WHEN_NOT_CHANGED)
+ o->do_callback();
+ }
+
if (o->callback() != default_callback)
o->Fl_Widget::clear_changed();
}
@@ -96,6 +119,7 @@ public:
inp_w(), inp_h());
inp_->callback(inp_cb, (void*)this);
inp_->box(FL_FLAT_BOX); // cosmetic
+ inp_->when(FL_WHEN_CHANGED|FL_WHEN_NOT_CHANGED);
menu_ = new InputMenuButton(menu_x(), menu_y(),
menu_w(), menu_h());
menu_->callback(menu_cb, (void*)this);
diff --git a/src/Fl_Button.cxx b/src/Fl_Button.cxx
index 984ecf0a2..a3f0a8d6a 100644
--- a/src/Fl_Button.cxx
+++ b/src/Fl_Button.cxx
@@ -85,7 +85,10 @@ int Fl_Button::handle(int event) {
if (type() == FL_RADIO_BUTTON) newval = 1;
else newval = !oldval;
} else
+ {
+ clear_changed();
newval = oldval;
+ }
if (newval != value_) {
value_ = newval;
set_changed();
@@ -103,6 +106,7 @@ int Fl_Button::handle(int event) {
else if (type() == FL_TOGGLE_BUTTON) oldval = value_;
else {
value(oldval);
+ set_changed();
if (when() & FL_WHEN_CHANGED) do_callback();
}
if (when() & FL_WHEN_RELEASE) do_callback();
diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx
index ffd8bf230..326b1fd66 100644
--- a/src/Fl_Input.cxx
+++ b/src/Fl_Input.cxx
@@ -409,9 +409,10 @@ int Fl_Input::handle(int event) {
// user double or triple clicked to select word or whole text
copy(0);
}
- // For output widgets, do the callback so the app knows the user
- // did something with the mouse...
- if (readonly()) do_callback();
+
+ // perform the RELEASE callback
+ if (when() & FL_WHEN_RELEASE)
+ maybe_do_callback();
return 1;
case FL_DND_ENTER:
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index be6448640..e4ae2e9a6 100644
--- a/src/Fl_Input_.cxx
+++ b/src/Fl_Input_.cxx
@@ -715,7 +715,9 @@ int Fl_Input_::handletext(int event, int X, int Y, int W, int H) {
} else //if (Fl::selection_owner() != this)
minimal_update(mark_, position_);
case FL_HIDE:
- if (when() & FL_WHEN_RELEASE) maybe_do_callback();
+ if (!readonly() &&
+ (when() & (FL_WHEN_RELEASE | FL_WHEN_NOT_CHANGED)))
+ maybe_do_callback();
return 1;
case FL_PUSH: