FLTK logo

Re: [fltk.general] Fl_Check_Browser callback does not get called.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Fl_Check_Browser callback does not get called. Albrecht Schlosser Jun 13, 2021  
 
On 6/13/21 6:17 PM aditya...@gmail.com wrote:
Hi,
It seems like `Fl_Check_Browser`'s callback doesn't get called when items are selected and deselected. I tried the example program compiled with the last FLTK commit (#986a8b33a2b5e503dd36ddbc8283d489ebbd9290) below with both keyboard and mouse input:

This is correct although AFAICT undocumented. The default when() condition of Fl_Check_Browser is FL_WHEN_NEVER which obviously does not call the callback. I can't tell why this is so, but I believe this should be documented. It's obviously unexpected behavior.

See comment below to make the program do what you (seem to) expect.

#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Check_Browser.H>

void CB(Fl_Widget*, void *) {
  puts("In the callback");
}

int main(int argc, char *argv[]) {
  Fl::scheme("gtk+");
  Fl_Double_Window *win = new Fl_Double_Window(250, 120, "Simple Browser");
  win->begin();
  {
    {
      Fl_Check_Browser *brow = new Fl_Check_Browser(10, 10, win->w()-20, 80, "Check");
      brow->callback(CB);

// add here:

brow->when(FL_WHEN_CHANGED);

      brow->add("Aaa");
      brow->add("Bbb");
      brow->add("Ccc");
      brow->add("Ddd");
      brow->checked(1,1);
      brow->checked(2,1);
    }
  }
  win->end();
  win->resizable(win);
  win->show(argc, argv);
  return(Fl::run());
}


--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/53b6316b-7e53-e25a-491e-24f4e5357187%40online.de.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.