Re: check-button & menu
Your create-button code replaced the layout-description of the pinboard with a new layout-description (containing only one checkbox).
Change the code so that it adds the checkbox to the layout-description, resulting in a layout-description with two checkboxes.
Below, I've made a few changes to your code to give you an idea. I use (push ...) in create-button, and I've changed the :y's so that the checkboxes don't overlay one another.
(Note that this example code will continue to prepend checkboxes to the layout-description forever. You will have to rewrite the code to remove checkboxes when you don't want them anymore).
pt
#|
Hi,I have a problem with the creation of a check-button and menu.
In the following code, If you press “Search Method1” is created a check-button
and after if you press "Method1" deleted the check-button “Search Method1”.
So,I want to press "search Method1" and "Method1" to create two check-button
"search Method1" & "Method1" in the pinboard-layout.
Thanks in advance
|#
(defun create-button (pinboard-layout-1 title text &optional (x 0) (y 0) data
interface)
(push
(make-instance 'capi:check-button :title title :title-position
:center :selected t :text text :x x :y y)
(capi:layout-description pinboard-layout-1)))
(defun f1(data interface &rest args)
(with-slots (pinboard-layout-1) interface
(declare (ignore args))
(create-button pinboard-layout-1 "search" "search Method1" 30 50 args)))
(defun f2(data interface &rest args)
(with-slots (pinboard-layout-1) interface
(declare (ignore args))
(create-button pinboard-layout-1 "search" "search Method2" 30 100 args)))
(defun f3(data interface &rest args)
(with-slots (pinboard-layout-1) interface
(declare (ignore args))
(create-button pinboard-layout-1 "Method" " Method1" 30 150 args)))
(capi:define-interface interface-1 ()
()
(:menu-bar menu-1 menu-2)
(:menus
(menu-2
"Search"
(("search Method1"
:callback 'f1)
("Search Method 2"
:callback 'f2)))
(menu-1
"Method"
(("Method1"
:callback 'f3))))
(:layouts
(pinboard-layout-1 capi:pinboard-layout ()))
(:default-initargs
:best-height 280
:best-width 300
:layout 'pinboard-layout-1
:title "Interface-1"))
(capi:display (make-instance 'interface-1))