Lisp HUG Maillist Archive

CAPI: Adding a push-button to an interface after displaying the interface

Hello all,

I have an interface that gets displayed as a window. The interface is created using make-instance like this:

(defun make-simple-capi-interface (&key create-cb destroy-cb)
  (make-instance 'capi:interface
		 :title "MAIN"
		 :menu-bar-items nil
		 :auto-menus nil
		 :message-area t
		 :enable-tooltips t
		 :help-callback nil
		 :external-border nil
		 :internal-border nil
		 :visible-border nil
		 :geometry-change-callback nil
		 :iconify-callback nil
		 :iconize-callback nil
		 :display-state :normal
		 :transparency 100
		 :window-styles nil
		 #|
		 :toolbar-items nil
		 :toolbar-states nil
		 :default-toolbar-states nil
		 |#
		 :create-callback create-cb
		 :destroy-callback destroy-cb
		 :best-width 800
		 :best-height 600
		 :best-x 0
		 :best-y 0
		 :visible-min-width 800
		 :visible-min-height 600
		 ))

Simple, and works. Now I also create a push-button that I want to add to the interface. It really should just be a simple push-button that also gets created with make-instance 'capi:push-button.

Now I would like to add this button to the interface at run-time. I can’t figure out how to do this … Any hints very welcome!
(Yes, bloody beginner here re CAPI).

Kind regards

   Frank


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: CAPI: Adding a push-button to an interface after displaying the interface

Hi,

You need to define a layout for the interface, and then you can push the button to that layout’s description. For example

(let ((interface (capi:display (make-instance 'capi:interface
                                             :title "MAIN"
                                             :layout (make-instance 'capi:column-layout)
                                             ; other parameters...
                                             ))))
 (capi:execute-with-interface interface
                              (lambda ()
                                (push (make-instance 'capi:push-button :text "A Button") (capi:layout-description (capi:pane-layout interface))))))

You may want to take a look the documentation for capi:layout, to see the different layout options:
http://www.lispworks.com/documentation/lw70/CAPI-W/html/capi-w-383.htm to 

Erik


> 15 juni 2017 kl. 18:41 skrev Frank Gönninger | Gönninger B&T <frank.goenninger@goenninger.net>:
> 
> Hello all,
> 
> I have an interface that gets displayed as a window. The interface is created using make-instance like this:
> 
> (defun make-simple-capi-interface (&key create-cb destroy-cb)
>  (make-instance 'capi:interface
> 		 :title "MAIN"
> 		 :menu-bar-items nil
> 		 :auto-menus nil
> 		 :message-area t
> 		 :enable-tooltips t
> 		 :help-callback nil
> 		 :external-border nil
> 		 :internal-border nil
> 		 :visible-border nil
> 		 :geometry-change-callback nil
> 		 :iconify-callback nil
> 		 :iconize-callback nil
> 		 :display-state :normal
> 		 :transparency 100
> 		 :window-styles nil
> 		 #|
> 		 :toolbar-items nil
> 		 :toolbar-states nil
> 		 :default-toolbar-states nil
> 		 |#
> 		 :create-callback create-cb
> 		 :destroy-callback destroy-cb
> 		 :best-width 800
> 		 :best-height 600
> 		 :best-x 0
> 		 :best-y 0
> 		 :visible-min-width 800
> 		 :visible-min-height 600
> 		 ))
> 
> Simple, and works. Now I also create a push-button that I want to add to the interface. It really should just be a simple push-button that also gets created with make-instance 'capi:push-button.
> 
> Now I would like to add this button to the interface at run-time. I can’t figure out how to do this … Any hints very welcome!
> (Yes, bloody beginner here re CAPI).
> 
> Kind regards
> 
>   Frank
> 
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Updated at: 2020-12-10 08:31 UTC