Re: Changing choice selections & triggering callbacks?
* Joshua TAYLOR <1c3ea73c1001241443l4a09577erceea9a040e05c4d3@mail.gmail.com> :
Wrote on Sun, 24 Jan 2010 17:43:20 -0500:
| Is there a way to programatically modify the selection of a
| capi:choice such that the appropriate selection-, retract-, and
| extend-callbacks get triggered? I'm working on a UI that has a
| selection and I can avoid some plumbing by including capi:choice as a
| superclass if I can tie the input-model to selection modifying calls.
| I tried (setf (capi:choice-selection ...) ...), but that doesn't
| trigger the callbacks, as shown by the code below. Implementing
| choice-like behavior isn't all that hard, but I'd avoid reimplementing
| if possible. Thanks in advance, //JT
What would help, IMO is if CAPI exposed a general CALL-CALLBACK method,
which would take a callbacks object, a callback-kind, and the data with
which to call the callback.
For Eg.: (CALL-CALLBACK OBJ :RETRACT-CALLBACK 'THREE)
would figure out that (capi:callbacks-callback-type obj) is :FULL (say),
and then it would evaluate
(funcall (capi:callbacks-retract-callback obj)
'three obj (capi:element-interface-for-callback obj))
as appropriate.
If CALL-CALLBACK were available, you could easily write a mixin class
with an around method on (SETF:CAPI-CHOICE-SELECTION) which could figure
out the callback-kind (i.e. RETRACT-CALLBACK or whatever--- depending on
what changed) and the data, and then call CALL-CALLBACK explicitly in
your user code, rather than code up a CHOICE element from scratch.
I don't think this is available as it stands, and it would probably come
at the cost of complicating the CAPI model slightly: As I understand it,
callbacks are only executed by CAPI in reaction to GUI events, and never
by the user.
--
Madhu