Re: Adding/removing buttons at runtime
All CAPI setter functions should trigger a redraw automatically (see
http://www.lispworks.com/documentation/lw70/CAPI-M/html/capi-m-28.htm).
I'm not sure what you tried that didn't work, but maybe you forgot to add the
buttons layout to the main layout?
--
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/
>>>>> On Tue, 15 Aug 2017 12:34:44 -0600, Laughing Water said:
>
> Thanks, Martin, that looks like exactly what I needed.
>
> Is there a general rule for what triggers a redraw of a GUI item? Is it documented in the CAPI manual?
>
> Regarding the surrounding discussion of an IDE, which is totally about making things easier for the programmer, to me this is an example of something that could be much more immediately straightforward and accessible but isn’t.
>
> While saying this, I have to add that I can only be humble when it comes to my expertise as a programmer. So forgive me if I’ve overlooked something obvious or have simply made less effort than LispWorks demands.
>
> I’ll also try to add to that IDE discussion if I can offer anything by way of solutions.
>
> LW
>
> > On Aug 15, 2017, at 7:52 AM, Martin Simmons <martin@lispworks.com> wrote:
> >
> > Hi Laughing Water,
> >
> > I'm not sure what you tried, but the following works for me:
> >
> > (defparameter *in* t)
> >
> > (defun click-clock-button (interface)
> > (setf *in* (not *in*))
> > (setf (capi:item-text (clock interface))
> > (if *in* "You're in!" "You're out!"))
> > (setf (capi:layout-description (buttons interface))
> > (when (not *in*)
> > (list
> > (make-instance 'capi:push-button :text "Grocery")
> > (make-instance 'capi:push-button :text "Produce")))))
> >
> > (capi:define-interface clock-interface ()
> > ()
> > (:panes
> > (clock capi:push-button
> > :accessor clock
> > :text "Clock In/Out"
> > :visible-min-width '(character 20)
> > :selection-callback 'click-clock-button
> > :callback-type :interface))
> > (:layouts
> > (buttons capi:column-layout
> > '()
> > :accessor buttons)
> > (main-layout capi:column-layout '(clock buttons) :gap 10 :adjust :center))
> > (:default-initargs :title "Button Test" :layout 'main-layout))
> >
> > (capi:display (make-instance 'clock-interface))
> >
> > --
> > Martin Simmons
> > LispWorks Ltd
> > http://www.lispworks.com/
> >
> >
> >>>>>> On Sat, 12 Aug 2017 17:10:55 -0600, Laughing Water said:
> >>
> >> My aim is have my time clock app handle people who work in multiple departments. Currently, with single departments only, an employee either double-clicks his/her name in a LIST-PANEL or clicks on the name and then on a button (appropriately labeled “Clock Joe In” or “Clock Joe Out”) to clock in or out.
> >>
> >> For the vast majority of employees, who are single-department, I want to keep it that simple. For multi-department employees the simplest thing I can think of is to replace the single CLOCK IN/OUT button with a button for each of the departments they could be clocking into.
> >>
> >> I was hoping there would be a simpler way than this stripped-down code (on Mac OS, by the way):
> >>
> >> (defparameter *in* t)
> >>
> >> (defun click-clock-button (interface)
> >> (setf *in* (not *in*))
> >> (setf (capi:item-text (clock interface))
> >> (if *in* "You're in!" "You're out!"))
> >> (setf (capi:pane-layout interface)
> >> (make-instance 'capi:column-layout
> >> :description
> >> (append
> >> (list (clock interface))
> >> (when (not *in*)
> >> (list
> >> (make-instance 'capi:push-button :text "Grocery")
> >> (make-instance 'capi:push-button :text "Produce")))))))
> >>
> >> (capi:define-interface clock-interface ()
> >> ()
> >> (:panes
> >> (clock capi:push-button
> >> :accessor clock
> >> :text "Clock In/Out"
> >> :visible-min-width '(character 20)
> >> :selection-callback 'click-clock-button
> >> :callback-type :interface))
> >> (:layouts
> >> (main-layout capi:column-layout '(clock ) :gap 10 :adjust :center))
> >> (:default-initargs :title "Button Test"))
> >>
> >> (capi:display (make-instance 'clock-interface))
> >>
> >> I tried including a BUTTONS pane (whether a COLUMN-LAYOUT or PUSH-BUTTON-PANEL) in the CLOCK-INTERFACE and simply SETFing the ITEMS or DESCRIPTION of that pane. I can see from (BUTTONS interface) that it works, but then, even trying an assortment of SETFing, INVALIDATE-RECTing, etc., I couldn’t get the result to show up in the CLOCK-INTERFACE window.
> >>
> >> So this simplified code succeeds, but the CLICK-CLOCK-BUTTON callback would have to include the entire PANE-LAYOUT for the window. The actual layout is not terribly complicated, but this seems like a clumsy solution.
> >>
> >> ALTERNATIVES
> >> I expect someone will offer a completely different approach, like opening a dialog window or having a pop-up menu to select the department, but I want to preserve two-click simplicity for the single-department people and not tax the dexterity of people who may be clumsy with computers. I’m open to alternative design ideas, but I’d still like to see a solution to the problem as I’m posing it.
> >>
> >> _______________________________________________
> >> 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
> >
>
>
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html