[cells-devel] Re: Celtk/Cells: Need a little help...

Frank Goenninger fgoenninger at prion.de
Wed Apr 12 20:38:25 UTC 2006


Am 12.04.2006 um 22:26 schrieb Ken Tilton:

>
>>
>>                      (setf (pb-state (fm^ :oper-mode-pb)) ;; FRGO:  
>> HERE !!!
>>                           (on-off-toggle
>>                             (fm^v :oper-mode-pb))))))  ;; FRGO:  
>> HERE !!!
>
>
> (mk-menu-entry-command
>                :label "Action: Push the OPER MODE button"
>                        :command (c? (tk-callback .tkw 'push-oper- 
> mode-pb
>                       (lambda ()
>                     (setf (fm^v :oper-mode-pb) ;; FRGO: HERE !!!
>                          (on-off-toggle
>                            (fm^v :oper-mode-pb))))))  ;; FRGO:  
> HERE !!!
>             )
>
> We have three slots in play now: .md-value, enabled, and pb- 
> state. .md-value because fm^v expands to (md-value (fm^ ...))
>
> As the ltktest-cells-inside doc says, I like to use the slot md- 
> value of an instance the same way TK treats the name of an instance  
> as a variable, namely to hold the key value that instance  
> represents in the application.
>
> It is not clear to me that enabled is that slot, even tho you have  
> the pb-state initarg associated with it. I would think that pb- 
> state is currently playing the key role of holding the key on/off  
> value. This is confirmed by you setting the toggle result into pb- 
> state.
>
> On the other hand, I see pb-state is ephemeral. I also see:
>
> (defmacro push-the-button (button-id)
>  `(setf (fm^v ,button-id) :pressed))
>
> Now there you are setting the md-value to :pressed, but since I see  
> toggle intentions, I am guessing this is a button that gets pressed  
> and then released then pressed again, and the second time produces  
> the opposite value as the first. So, putting it all together (and  
> throwing out altogether enabled since I see that is not yet  
> implemented):
>
> (defmodel pushbutton (application-object)
>  ((.md-value :cell t :accessor pb-state :initform (c-in :off))))
>
> (mk-menu-entry-command
> :label "Action: Push the OPER MODE button"
> :command (c? (tk-callback .tkw 'push-oper-mode-pb
>                (lambda ()
>                  (setf (fm^v :oper-mode-pb)
>                    (on-off-toggle
>                     (fm^v :oper-mode-pb)))))))
>
> If you want to get a little fancier:
>
> (defmodel pushbutton (application-object)
>  ((.md-value :cell t :accessor pb-state
>     :initform (c? (if (^pressed)
>                       (on-off-toggle .cache)
>                     (initial-pb-state self))))
>   (pressed :cell :ephemeral :intiform (c-in nil) ... etc)
>   (initial-pb-state :cell nil ....etc )))
>
> (mk-menu-entry-command
> :label "Action: Push the OPER MODE button"
> :command (c? (tk-callback .tkw 'push-oper-mode-pb
>                (lambda ()
>                  (setf (pressed (fm^ :oper-mode-pb)) t)))))
>
> The latter can be good for doing things like associating a click  
> sound with the button press, because then you just have other cells  
> watching (^pressed). Otherwise you end up loading more and more  
> code into the menu callback.
>
> hth, ken

You wonder if this helps? You just not only discovered some bugs but  
also explained to me .cache and real use of .md-value ...

It certainly helps!!

Thanks so much.

Frank




More information about the cells-devel mailing list