Hello,
I'm writing an application (using latest FLTK 2 snapshots), and began adding
custom dialog windows. It contains a GlWindow object that opens a custom dialog
on right click event. Such custom dialog opens properly when called through a
menu item, but hangs in Window.exec() function when called right after calling
the file_chooser dialog. This happens when loading a file and right clicking in
the GL view (calling the same dialog from a menu item never hangs).
The code below shows the bug, opening the 'Dialog' item from the File menu
works properly, while calling the 'Open' one (click either OK or Cancel) hangs
the window.
The my_dialog function is called right after fltk::file_chooser() in
on_menu_file_open(), there might be something to do in between to prevent the
bug. Tested on one platform only : Ubuntu 7 (i386).
Thanks for any help,
Romain
#include <fltk/Window.h>
#include <fltk/Item.h>
#include <fltk/ItemGroup.h>
#include <fltk/MenuBar.h>
#include <fltk/events.h>
#include <fltk/file_chooser.h>
#include <fltk/filename.h>
#include <iostream>
#include <string>
static int my_dialog()
{
// build dialog window
fltk::Window window(fltk::USEDEFAULT, fltk::USEDEFAULT, 400, 200,
"Properties", true);
window.begin();
// ...
window.end();
// show it
std::cerr << "start" << std::endl;
window.exec();
std::cerr << "end" << std::endl;
return 0;
}
class application_window : public fltk::Window
{
public:
application_window();
private:
void on_menu_file_open(fltk::Widget*);
void on_menu_dialog(fltk::Widget*);
static void cb_menu_file_open(fltk::Widget* W, void* Data) {
((application_window*)Data)->on_menu_file_open(W); }
static void cb_menu_dialog(fltk::Widget* W, void* Data) {
((application_window*)Data)->on_menu_dialog(W); }
};
static application_window* application_pointer = 0;
void application_window::on_menu_file_open(fltk::Widget*)
{
char result[2048];
fltk::filename_absolute(result, 2048, ".");
const char* file = fltk::file_chooser("Open file", "*", result);
if(my_dialog())
{
}
}
void application_window::on_menu_dialog(fltk::Widget*)
{
if(my_dialog())
{
}
}
application_window::application_window() :
Window(fltk::USEDEFAULT, fltk::USEDEFAULT, 300, 200, "Test", true)
{
user_data((void*)(this));
begin();
// main menu bar
fltk::MenuBar* left_menu_bar = new fltk::MenuBar(0, 0, 300, 20,
"Menu");
left_menu_bar->begin();
// file menu
fltk::ItemGroup* menu_file = new
fltk::ItemGroup("&File");
menu_file->begin();
fltk::Item* menu_file_open = new
fltk::Item("Open");
menu_file_open->callback((fltk::Callback*)cb_menu_file_open, this);
fltk::Item* menu_file_dialog = new
fltk::Item("Dialog");
menu_file_dialog->callback((fltk::Callback*)cb_menu_dialog, this);
menu_file->end();
left_menu_bar->end();
end();
}
// Main
#include <fltk/run.h>
#include <fltk/visual.h>
int main(int argc, char** argv)
{
fltk::visual(fltk::DOUBLE_BUFFER);
application_pointer = new application_window();
application_pointer->show();
return fltk::run();
}
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev