Re: capi:interface-display for dialogs

"Erik Ronström (as erik dot ronstrom at doremir dot com)" <[email protected]>
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
This has always bugged me as well.


> Sometimes initialization code can be put in the create-callback of your interface, though adding it in suitable methods for initialize-instance or interface-display is usually better.

I’ve always wondered in what way it is ”better”. The documentation for interface also says:

> Note: create-callback should be used only for operations that must be done with the interface already created and cannot be done in interface-display. Otherwise they should be either done in initialize-instance or between your calls to make-instance and display. An operation that needs to run after the interface is created but just before displaying the interface as an ordinary window (typical cases are font queries and loading images) can be put in the interface-display :before method. An operation that needs to run just after displaying the interface as an ordinary window can be put in the interface-display :after method.


Again, I find it unclear WHY create-callback should be avoided – what are the dangers or drawbacks with the callback that makes it a last resort?



This being said, I’ve successfully called cocoa from the create-callback in the past, for instance:

(capi:display-dialog
 (make-instance 'capi:interface
                :layout (make-instance 'capi:column-layout
                                       :visible-min-height 100
                                       :visible-min-width 200
                                       :description (list (make-instance 'capi:push-button
                                                                         :text "Close"
                                                                         :callback 'capi:abort-dialog
                                                                         :callback-type :none)))
                :create-callback (lambda (interface)
                                   #+cocoa
                                   (let ((representation (slot-value (capi-internals:representation interface) 'capi-cocoa-library::window)))
                                     (objc:invoke representation "setContentBorderThickness:forEdge:" 50.0 1))))
 :owner (capi:convert-to-screen))



Erik



_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.