Thanks for your help again.  Eliminating the constructor worked.  I was using 
an example for creating a custom window to create my custom button.  It's more 
of a template than a custom button.

Again thank you both for the help.

>
> On 16 Oct 2012, at 20:36, Doug Parks wrote:
>
> > I decided to make a custom button class so that I could reduce the =
> amount of code in my project.  I was able to create the button but when =
> I click on the button, the callback isn't being called.  Before I made =
> the custom button class the button worked fine.  Below is an excerpt =
> from my code.
> >=20
> > class newButton : public Fl_Button
> > {
> >   Fl_Button *myButton;
> >   public:
> >   newButton(int x, int y, int w, int h, const char * l =3D =
> 0):Fl_Button(x, y, w, h, l)
> > {
> >   myButton =3D new Fl_Button(x, y, w, h, l);
> >   myButton->box(FL_GTK_ROUND_UP_BOX);
> >   myButton->color((Fl_Color)24);
> >   myButton->selection_color((Fl_Color)24);
> >   myButton->labelcolor(FL_WHITE);
> >   myButton->labelfont(1);
> > }
> > };
> >=20
> > newButton accept(687, 652, 75, 25, "Accept");
> > accept.callback(accept_cb);
> >=20
> > The callback is supposed to open a new window and close the current =
> window but it isn't doing anything at the moment.
> >=20
> > Any help would be appreciated, thanks.
>
>
> Um, I may be missing something important, but why have you created a new =
> button inside your derived button class?
>
> In general, that is not needed...=20
>
> Here's a way to do this; perhaps this is what you meant?
>
> ---------
> // fltk-config --compile button-demo.cxx
>
> #include <FL/Fl.H>
> #include <FL/Fl_Double_Window.H>
> #include <FL/Fl_Button.H>
>
> class newButton : public Fl_Button
> {
>
> public:
>   newButton(int x, int y, int w, int h, const char * l =3D =
> 0):Fl_Button(x, y, w, h, l)
>   {
>     box(FL_GTK_ROUND_UP_BOX);
>     color((Fl_Color)24);
>     selection_color((Fl_Color)24);
>     labelcolor(FL_WHITE);
>     labelfont(1);
>   }
> };
>
> static Fl_Double_Window *main_win =3D (Fl_Double_Window *)0;
>
> static void cb_Quit(Fl_Button*, void*) {
>   if(main_win) main_win->hide();
> }
>
>
> int main(int argc, char **argv) {
>   main_win =3D new Fl_Double_Window(100, 100, 439, 321, "Main win");
>   main_win->begin();
>
>   newButton* myButton =3D new newButton(345, 265, 80, 35, "Quit");
>   myButton->callback((Fl_Callback*)cb_Quit);
>  =20
>   main_win->end();
>  =20
>   main_win->show(argc, argv);
>  =20
>   return Fl::run();
> } // main
>
> /* end of file */
> ---------
>
>
>
>
>
>

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to