> I have a checked menu item for which I would like to trigger the callback.
> I can change the state of the check. I see there is a method for
> Fl_Menu_Item to call the callback but cannot figure out which widget
> pointer I should supply?


Not exactly sure what it is you are asking about, but as a general note, I find 
that it is often instructive to create a little example of what I'm trying to 
do using fluid, then look at athe code it generated for insights into how to 
use the widgets...

e.g. (assuming this fluid file does what you want, of course!) this fluid file..

------------
# data file for the Fltk User Interface Designer (fluid)
version 1.0300 
header_name {.h} 
code_name {.cxx}
decl {\#include <stdio.h>} {selected private local
} 

Function {} {open
} {
  Fl_Window main_win {
    label {Test Window} open
    xywh {640 311 356 231} type Double visible
  } {
    Fl_Menu_Bar menu_bar {open
      xywh {0 0 356 20}
    } {
      Submenu menu1 {
        label {A Menu} open
        xywh {0 0 62 20}
      } {
        MenuItem item1 {
          label {Item 1}
          callback {puts("Item 1");
fflush(stdout);}
          xywh {0 0 30 20} type Toggle
        }
        MenuItem item2 {
          label {Item 2}
          callback {puts("Item 2");
fflush(stdout);}
          xywh {10 10 30 20} type Toggle
        }
        MenuItem item3 {
          label {Item 3}
          callback {puts("Item 3");
fflush(stdout);}
          xywh {20 20 30 20} type Toggle
        }
        MenuItem item4 {
          label {Item 4}
          callback {puts("Item 4");
fflush(stdout);}
          xywh {30 30 30 20} type Toggle
        }
      }
    }
  }
}

------------

Creates the following C++ output:

------------
// generated by Fast Light User Interface Designer (fluid) version 1.0300

#include "menu-chk.h"
#include <stdio.h>

Fl_Double_Window *main_win=(Fl_Double_Window *)0;

Fl_Menu_Bar *menu_bar=(Fl_Menu_Bar *)0;

static void cb_item1(Fl_Menu_*, void*) {
  puts("Item 1");
fflush(stdout);
}

static void cb_item2(Fl_Menu_*, void*) {
  puts("Item 2");
fflush(stdout);
}

static void cb_item3(Fl_Menu_*, void*) {
  puts("Item 3");
fflush(stdout);
}

static void cb_item4(Fl_Menu_*, void*) {
  puts("Item 4");
fflush(stdout);
}

Fl_Menu_Item menu_menu_bar[] = {
 {"A Menu", 0,  0, 0, 64, FL_NORMAL_LABEL, 0, 14, 0},
 {"Item 1", 0,  (Fl_Callback*)cb_item1, 0, 2, FL_NORMAL_LABEL, 0, 14, 0},
 {"Item 2", 0,  (Fl_Callback*)cb_item2, 0, 2, FL_NORMAL_LABEL, 0, 14, 0},
 {"Item 3", 0,  (Fl_Callback*)cb_item3, 0, 2, FL_NORMAL_LABEL, 0, 14, 0},
 {"Item 4", 0,  (Fl_Callback*)cb_item4, 0, 2, FL_NORMAL_LABEL, 0, 14, 0},
 {0,0,0,0,0,0,0,0,0},
 {0,0,0,0,0,0,0,0,0}
};

int main(int argc, char **argv) {
  { main_win = new Fl_Double_Window(356, 231, "Test Window");
    { menu_bar = new Fl_Menu_Bar(0, 0, 356, 20);
      menu_bar->menu(menu_menu_bar);
    } // Fl_Menu_Bar* menu_bar
    main_win->end();
  } // Fl_Double_Window* main_win
  main_win->show(argc, argv);
  return Fl::run();
}

------------

Does that help at all?




SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

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

Reply via email to