Where should you keep the data in a celtk app. I tried doing the following...
(defmodel app (window) ((my-model :initform nil :initarg :model :accessor my-model)) (:default-initargs :kids (c? (the-kids (mk-row (:packing (c?pack-self)) (mk-popup-menubutton :id :view-selector :initial-value (c? (first (^entry-values))) :entry-values (c? '(codelists items item-groups forms events))) (mk-text-widget :id :display :value (c? (if *odm* (case (selection (fm^ :view-selector)) (codelists (codelists *odm*)) (items (items *odm*)) (t (xml *odm*)))))))))))
...but I couldn't work out how to access my-model from the text widget's (c? ...). What you see above is what I changed it to in order to make it access the global *odm* variable which is elsewhere set to be a normal cells instance. Is there a way to keep it all in the app? I'd like to make it so that my-model is set by the result of a file-open dialog.
Cheers, Andy
Andy Chambers wrote:
Where should you keep the data in a celtk app. I tried doing the following...
(defmodel app (window) ((my-model :initform nil :initarg :model :accessor my-model)) (:default-initargs :kids (c? (the-kids (mk-row (:packing (c?pack-self)) (mk-popup-menubutton :id :view-selector :initial-value (c? (first (^entry-values))) :entry-values (c? '(codelists items item-groups forms events))) (mk-text-widget :id :display :value (c? (if *odm* (case (selection (fm^ :view-selector)) (codelists (codelists *odm*)) (items (items *odm*)) (t (xml *odm*)))))))))))
...but I couldn't work out how to access my-model from the text widget's (c? ...).
As long as you are using my Family class you have a name/typespace to work with, meaning various utilities prefixed "fm-" which navigate parent/kids to find things by name or type.
In your case, (my-model (upper self app)) or more succinctly since self is so common, (my-model (u^ app)). Poke around fm-utilities for more such.
You can also search for things by name:
(my-model (fm-other app))
If you do not want to use my Family class, just do something of your own which similarly effectively creates a namespace your own custom code is responsible for navigating.
cheers, ken