Torsten Giebl wrote: > For me the biggest problem was how to share data > between two or more windows. If you have an app where seperate windows > do not share data, great. But if you need to share data it can get harder.
I've found it can all work fairly easily if you make an application class, and put all windows in it, and then pass the application class as the 'user_data' to all callbacks, then the callbacks can always access all data in the application as needed. The other way I've gone is to make a 'Message' class that each window can 'subscribe' to, and pass text messages through that to send or request data. It's a fairly simple thing to write if you're familiar with string parsing, and is basically another way to make data 'globally accessible' without making scope changes to C++ variables, or doing tricky things with pointers. I'm thinking I posted a simple one of these message classes a looong time ago, not sure if it predates the archive or not. The gist of it was the main app created an instance of the Message class, and all the widgets/classes interested in receiving 'messages' would create their own instances of the class to register a name and callback. When any widget wanted to send a message, it would supply a 'to:' name (which could be '*' to make a broadcast to all widgets), and a message to send, which could be a string containing potentially multiple lines of data. The message class would just loop through all the registered 'listeners', invoking the callback for each that matched the 'to:' information, and then passing the callback the message string. This is handy for things like Preference settings, or just about any kind of event driven thing, like where one button changes the state in several widgets/windows/state variables throughout the app. _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

