Skip to content

Commit

Permalink
STR 1719: fixed inconsistencies with FL_WHEN_NOT_CHANGED
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@6031 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Matthias Melcher committed Feb 20, 2008
1 parent 97c408f commit dc0ab1d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -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)
Expand Down
38 changes: 31 additions & 7 deletions FL/Fl_Input_Choice.H
Expand Up @@ -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
Expand All @@ -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();
}
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/Fl_Button.cxx
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions src/Fl_Input.cxx
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/Fl_Input_.cxx
Expand Up @@ -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:
Expand Down

0 comments on commit dc0ab1d

Please sign in to comment.