Fltk按钮回拨

时间:2016-11-30 22:27:49

标签: c++ fltk

对于这个子窗口,我创建了一个按钮,但是当我点击按钮时没有任何反应。我想点击按钮后退出子窗口,但我不知道该怎么做。

void model(Fl_Widget *, void *) {
    Fl_Window *head = new Fl_Window(400, 350, "Robot Model: ");
    Fl_Input *input = new Fl_Input(200, 0, 100, 30, "Name: ");
    Fl_Input *input1 = new Fl_Input(200, 40, 100, 30, "Part-Number: ");
    Fl_Input *input2 = new Fl_Input(200, 80, 100, 30, "How much is the    Weight: ");
    Fl_Input *input3 = new Fl_Input(200, 120, 100, 30, "The Cost: ");
    Fl_Input *input4 = new Fl_Input(200, 160, 100, 30, "Brief Description:           ");
    Fl_Button *enter = new Fl_Button(150, 200, 100, 30, "Enter");
    head->show();
  }

int main(){

Fl_Window *win = new Fl_Window(600, 500, "Robot Workshop");
Fl_Box *box = new Fl_Box(0, 10, 600, 100, "Welcome to Robot Workshop!");
box->box(FL_UP_BOX);
box->labelsize(36);
box->labelfont(FL_BOLD + FL_ITALIC);
box->labeltype(FL_SHADOW_LABEL);
Fl_Menu_Bar *menu = new Fl_Menu_Bar(0, 0, 600, 25);
menu->add("Exit/Quit", FL_CTRL + 'v', Quit_CB);
menu->add("Project Manager/Robot Part/Head", FL_CTRL + 'h', head);
menu->add("Project Manager/Robot Part/Torso", FL_CTRL + 't', torso);
menu->add("Project Manager/Robot Part/Arm", FL_CTRL + 'a', arm);
menu->add("Project Manager/Robot Part/Battery", FL_CTRL + 'b', battery);
menu->add("Project Manager/Robot Part/Locomotor", FL_CTRL + 'l', locomotor);
menu->add("Project Manager/Robot Model" ,FL_CTRL + 'w', model);
menu->add("Beloved Customer/Browse Catalog", FL_CTRL + 'z', catalog);
menu->add("Beloved Customer/Part Pictures", FL_CTRL + 'v', pic);
menu->add("Manual", FL_CTRL + 'm', manual_window);

win->show();
return(Fl::run());

}

1 个答案:

答案 0 :(得分:0)

如果您想要回调,则需要添加回调函数。见http://www.fltk.org/doc-1.3/common.html

void xyz_callback(Fl_Widget *w, void *data) {
...
}

您可以将任何您喜欢的内容传递给数据并将其转换回原始类型。然后使用

修改您的按钮
button->callback(xyz_callback, &xyz_data);