Additional callbacks happening on Fl_Input_Choice

19 views
Skip to first unread message

pvr...@btinternet.com

unread,
May 20, 2024, 12:20:07 PMMay 20
to fltk.general
I updated FLTK a few hours ago do that I could test a patch in another conversation.

My app started to behave weirdly. I was getting callbacks for Fl_Input_Choice just moving windows around near it. I had set the widget when to FL_WHEN_RELEASE_ALWAYS and it seems this update has changed the behaviour:

philip@chinook:~/dev/fltk$ git diff  33b601e57404fcef058a992ba7767f2c4f16a81b fd791a068e39e06785adc44693f4c533d3d6c903 src/Fl_Input_Choice.cxx
diff --git a/src/Fl_Input_Choice.cxx b/src/Fl_Input_Choice.cxx
index fcb9f9c55..534e68f19 100644
--- a/src/Fl_Input_Choice.cxx
+++ b/src/Fl_Input_Choice.cxx
@@ -230,14 +230,21 @@ void Fl_Input_Choice::menu_cb(Fl_Widget*, void *data) {
 void Fl_Input_Choice::inp_cb(Fl_Widget*, void *data) {
   Fl_Input_Choice *o=(Fl_Input_Choice *)data;
   Fl_Widget_Tracker wp(o);
-  if (o->inp_->changed()) {
-    o->Fl_Widget::set_changed();
-    if (o->when() & (FL_WHEN_CHANGED|FL_WHEN_RELEASE))
-      o->do_callback(FL_REASON_CHANGED);
+  if (  (   (Fl::callback_reason()==FL_REASON_RELEASED)
+         || (Fl::callback_reason()==FL_REASON_LOST_FOCUS) )
+      && (o->when() & FL_WHEN_RELEASE) )
+  {
+    o->do_callback(FL_REASON_RELEASED);
   } else {
-    o->Fl_Widget::clear_changed();
-    if (o->when() & FL_WHEN_NOT_CHANGED)
-      o->do_callback(FL_REASON_RESELECTED);
+    if (o->inp_->changed()) {
+      o->Fl_Widget::set_changed();
+      if (o->when() & FL_WHEN_CHANGED)
+        o->do_callback(FL_REASON_CHANGED);
+    } else {
+      o->Fl_Widget::clear_changed();
+      if (o->when() & FL_WHEN_NOT_CHANGED)
+        o->do_callback(FL_REASON_RESELECTED);
+    }
   }
 
   if (wp.deleted()) return;
@@ -259,7 +266,7 @@ Fl_Input_Choice::Fl_Input_Choice (int X, int Y, int W, int H, const char *L)
   inp_ = new Fl_Input(inp_x(), inp_y(), 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);
+  inp_->when(FL_WHEN_CHANGED|FL_WHEN_NOT_CHANGED|FL_WHEN_RELEASE);
   menu_ = new InputMenuButton(menu_x(), menu_y(), menu_w(), menu_h());
   menu_->callback(menu_cb, (void*)this);
   end();

These additional callbacks were causing a lot of unnecessary validation and updates of windows. I have modified my application to check whether the value has changed before doing the validation, but I was wondering why the change.

Phil.

Albrecht Schlosser

unread,
May 21, 2024, 6:10:14 AMMay 21
to fltkg...@googlegroups.com
On 5/20/24 18:20 'pvr...@btinternet.com' via fltk.general wrote:
I updated FLTK a few hours ago do that I could test a patch in another conversation.

My app started to behave weirdly. I was getting callbacks for Fl_Input_Choice just moving windows around near it. I had set the widget when to FL_WHEN_RELEASE_ALWAYS and it seems this update has changed the behaviour:

philip@chinook:~/dev/fltk$ git diff  33b601e57404fcef058a992ba7767f2c4f16a81b fd791a068e39e06785adc44693f4c533d3d6c903 src/Fl_Input_Choice.cxx
diff --git a/src/Fl_Input_Choice.cxx b/src/Fl_Input_Choice.cxx
[...]
These additional callbacks were causing a lot of unnecessary validation and updates of windows. I have modified my application to check whether the value has changed before doing the validation, but I was wondering why the change.

Commit fd791a068e39e06785adc44693f4c533d3d6c903 does indeed change event handling of Fl_Input_Choice. It *might* have been an accidental commit of a work in progress because the commit message "Separate FLUID user documentation, screen shot automation (#936)" doesn't appear to be directly related to such a change - although it could have been to fix an issue with fluid. We need to ask the author...

Matthias, can you please shed some light on the changes in Fl_Input_Choice.cxx in this commit and their reasoning?

Matthias Melcher

unread,
May 26, 2024, 11:03:32 AMMay 26
to fltk.general


Sorry about the confusion and the additional work. This was a big commit and some untested code slipped into it. I reverted the issue and recommitted to master.



 - Matthias



Commit 2bab8c94ff0d2440520b0aeefc3edaec18c02595:


Revert InputChoice from  fd791a0


A change to Fl_Input_Choice callbacks slipped into

fd791a068e39e06785adc44693f4c533d3d6c903.

This Commit removes that change. It may need to be 

fixed and reapplied later in its own Commit. 




Philip Rose

unread,
May 27, 2024, 9:29:53 AMMay 27
to 'Matthias Melcher' via fltk.general


On 26/05/2024 16:03, 'Matthias Melcher' via fltk.general wrote:


Sorry about the confusion and the additional work. This was a big commit and some untested code slipped into it. I reverted the issue and recommitted to master.



 - Matthias


Thanks Matthias,

I no longer see these call backs when the widget loses focus.

Phil.

Reply all
Reply to author
Forward
0 new messages