I'm picking up this old story about the osnap function.
What i really would like is to isolate the osnapz toggle function, written without opendcl code.
Meaning a reactor controls the grid in conjuction with the osnapz setting.
That would be a great function for wider use.
I isolates some code to start. But i am not experienced enough to get this to work propertly.
Maybe someone can help me with this.
Thanks!
(defun Osnapz-OnLoad () ; based on the work of Roy
;; Remove existing reactors:
(mapcar '(lambda (rea)
(if (= "OSNAPZ" (vlr-data rea))
(vlr-remove rea)
)
)
(apply 'append (mapcar 'cdr (vlr-reactors)))
)
;; Create new reactors:
(vlr-sysvar-reactor
"OSNAPZ"
'((:vlr-sysvarchanged . Osnaps-CallBackSysvarChanged)
(:vlr-sysvarwillchange . Osnaps-CallBackSysvarWillChange)
)
)
(vlr-docmanager-reactor
"OSNAPZ"
'((:vlr-documentbecamecurrent . Osnaps-CallBackDocumentBecameCurrent)
(:vlr-documenttobedeactivated . Osnaps-CallBackDocumentToBeDeactivated)
)
)
(vlr-command-reactor
"OSNAPZ"
'((:vlr-commandcancelled . Osnaps-CallBackCommandCancelled)
(:vlr-commandfailed . Osnaps-CallBackCommandCancelled)
(:vlr-commandwillstart . Osnaps-CallBackCommandWillStart)
)
)
(princ)
)
(defun Osnaps-CallBackSysvarChanged (rea lst)
(cond ((= "OSNAPZ" (car lst)) (Osnaps-UpdateOsnapz nil)))
)
(defun Osnaps-CallBackDocumentBecameCurrent (rea lst)
(Osnaps-UpdateOsnapz nil)
)
(defun Osnaps-CallBackDocumentToBeDeactivated (rea lst)
(Osnaps-UpdateOsnapz T)
)
(defun Osnaps-UpdateOsnapz (disableP / btn)
(if (setq btn Osnaps/Main/btnOsnapz)
(cond
(disableP
(dcl-Control-SetBackColor btn -16) ; here .., no opendcl codes ..
(dcl-Control-SetForeColor btn -19) ; here .., no opendcl codes ..
)
((zerop (getvar 'osnapz))
(dcl-Control-SetBackColor btn 0) ; here .., no opendcl codes ..
(dcl-Control-SetForeColor btn 7) ; here .., no opendcl codes ..
)
(T
(dcl-Control-SetBackColor btn 7) ; here .., no opendcl codes ..
(dcl-Control-SetForeColor btn 0) ; here .., no opendcl codes ..
)
)
)
)
; not working yet though