Re: Push-button & Menu
On Thursday 28 May 2009 10:33:55 am Foteini Grivokostopoulou wrote:
>
> Hi, I have a problem with the creation of a push-button.
Change f1 to be:
(defun f1(data interface)
(let ((button1 (make-instance 'capi:push-button
:text "button1"
;:internal-border 20
:visible-min-width 200)))
(setf (capi:layout-description (slot-value interface 'pinboard-layout-1))
(list (make-instance 'capi:push-button-panel
:items (list button1)
:layout-args '(:x-gap 30)
:x 30
:y 100)))))
Your version of f1 used capi:contain, which opens a new window (a "container" for testing purposes).
Capi layouts have a (list) field called a "description", accessible with the function capi:layout-description. The items managed by the layout must be in the description list. Normally you would stick items into the description using the '( ... ) arguments in the capi:define-interface macro, but that adds them statically (you could use capi:hide-pane / show-pane to turn them off/on), but, in your example code you seemed to want to add a button dynamically, hence, you have to alter the description dynamically.
(You should be able to use capi:manipulate-pinboard to change the description, but when I tried it, it complained that push-button-panel is not a pinboard-object.)
Note that, for this simple example, you don't even need the push-button-panel, you can just add an :x and :y to the button1 and throw it directly into the description list.
In general, if you are laying out a GUI, try using the other layout helper classes, like row-layout, column-layout, grid-layout, etc. They automagically pack your items together and handle resizing of the gui, whereas a pinboard layout will not reposition your button if your resize. Same deal with those classes - if you really need to add/remove buttons dynamically, you do it by altering their capi:layout-description's.
pt