Hi<div><br></div><div>I have the following code:</div><div><br></div><div><div>(defmacro defonevent (onevent eventtype xstruct)</div><div><div> `(defmacro ,onevent (&rest body)</div><div> `(progn</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>(if (null (gethash (window *context*) %event-handlers%))</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (setf (gethash (window *context*) %event-handlers%) (make-hash-table)))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>(setf (gethash ,',eventtype (gethash (window *context*) %event-handlers%))</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> #'(lambda (event) </div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (macrolet ((this (var) `(xpref event ',',',xstruct ,var)))</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (this window) ; to avoid the warning if the event is not used in the body</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> ,@body))))))</div>
<div><br></div><div>(defonevent on-expose #$Expose :<XE>xpose<E>vent)</div><div>(defonevent on-buttonpress #$ButtonPress :<XB>utton<E>vent)</div><div>(defonevent on-buttonrelease #$ButtonRelease :<XB>utton<E>vent)</div>
<div>(defonevent on-keypress #$KeyPress :<XK>ey<E>vent)</div><div>(defonevent on-keyrelease #$KeyRelease :<XK>ey<E>vent)</div><div>(defonevent on-clientmessage #$ClientMessage :<XC>lient<M>essage<E>vent)</div>
<div>(defonevent on-mapnotify #$MappingNotify :<XM>ap<E>vent)</div><div><br></div><div><br></div><div>; usage</div><div>(cell ....</div><div> (on-expose</div><div> (drawline 0 0 (this width) (this height)))</div>
<div> ...</div><div> )</div><div><br></div><div><br></div><div>The issue is that I do not know how to implement xpref. The pref macro takes an accessor of the form</div><div>type.field but I need a macro that takes the type of the structure and the field name separately.</div>
<div><br></div><div>Thank you for your help</div><div><br></div><div>Taoufik</div></div></div>