summaryrefslogtreecommitdiff
path: root/src/Fl_Input_Choice.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2026-01-07 13:18:29 +0100
committerMatthias Melcher <github@matthiasm.com>2026-01-07 13:18:29 +0100
commitdc07fcdb6e34c2595d2f70782762beb6603dc342 (patch)
tree5aae20ff5fd2e9e2cabbc8c766982c2a6a98c07a /src/Fl_Input_Choice.cxx
parent52452f117fb7d54e52790d54a98909a8002dfba9 (diff)
Fix callback forwarding in Fl_Input_Choice.
Widget would always call CHANGED but never RELEASE events, no matter how the when() flags were set.
Diffstat (limited to 'src/Fl_Input_Choice.cxx')
-rw-r--r--src/Fl_Input_Choice.cxx15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Fl_Input_Choice.cxx b/src/Fl_Input_Choice.cxx
index ea5fb35e5..e01743eb6 100644
--- a/src/Fl_Input_Choice.cxx
+++ b/src/Fl_Input_Choice.cxx
@@ -244,12 +244,17 @@ void Fl_Input_Choice::inp_cb(Fl_Widget*, void *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);
} else {
o->Fl_Widget::clear_changed();
- if (o->when() & FL_WHEN_NOT_CHANGED)
- o->do_callback(FL_REASON_RESELECTED);
+ }
+ if (Fl::callback_reason() == FL_REASON_LOST_FOCUS) {
+ if (o->when() & FL_WHEN_RELEASE)
+ o->do_callback(FL_REASON_LOST_FOCUS);
+ } else {
+ if (o->inp_->changed() && (o->when() & FL_WHEN_CHANGED))
+ o->do_callback(Fl::callback_reason());
+ else if (o->when() & FL_WHEN_NOT_CHANGED)
+ o->do_callback(Fl::callback_reason());
}
if (wp.deleted()) return;
@@ -270,7 +275,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();