-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi list,
Suppose you're creating a graphical user interface to some external key-value store. Your interface consists of a number of tabs each of which contains some input fields and some output fields (potentially created automatically according to the values of certain fields of the store which can be changed on a different tab). For example the store might have entries for the dimensions of a 2-dimensional matrix, its constituent elements and for each row and column the sum-total of its elements. The user interface might consist of one tab to enter the dimensions (dimension-tab) and another tab (element-tab) with input fields for each element and output fields for the sum-totals of each row and each column. Whenever the element-tab becomes shown the number and type of its in- and output fields is recalculated (through an overridden on-superwindow-show method). Whenever the user changes the value of one of the elements of the matrix via an input field, the corresponding value in the store is changed and the row-sums and column-sums are updated automatically by the store. The question is now: ``How should the program automatically update the values of the changed output fields?''. I see a number of possibilities divided into two philosophies: Philosophy 1: All output fields have been potentially changed after any change in an input field. Idea 1: Call the tab's refresh method which should inform all its children to also refresh themselves. Hook into the refresh call of an output field and have it refresh its value from the store before refreshing its drawing. Unfortunately I'm a bit fuzzy on the details of this method override. Idea 2: Call the tabs get-children method to find its children. Examine those recursively with get-children (properly wrapped in an exception-catcher in case they don't have that method) and for each leaf child call its update-value-from-store method (again properly wrapped). Philosophy 2: Inform output fields when their values have been definitely changed. Idea A: Have each output field register somewhere that it wants to be notified of any changes to its value. When one of the dimensions changes the output fields should unregister (because they will be garbage collected) and the newly created output field should register in its stead. This can perhaps be accomplished with a collection of weak references to registered callbacks, though the details are unclear to me. Idea B: Create a FrTime signal for each output value in the store and hook those up to the output fields. Then FrTime handles the registering and deregistering of output fields and we only need to hook up the signals to the store. Which way would you go if you were creating this user interface? Thanks for your thoughts, Marijn -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8epF4ACgkQp/VmCx0OL2w+XACcD5wSfHR5YAuVvYQmasSmobQk PgoAn3fkgdudt1W0svORsQmH7uXD6xMe =bBLQ -----END PGP SIGNATURE----- ____________________ Racket Users list: http://lists.racket-lang.org/users