Lisp HUG Maillist Archive

Frustrations with popup-confirmer

Hello all
    I'd like someone to tell me what stupidity I'm committing with the
following code. I have a simple interface I want to wrap in a
popup-confirmer and my implementations for :value-function and
:ok-check will not enable the OK button. The code below will not
run on it's own but hopefully it's simple enough for someone to
spot my error. Note that it appears that although I call
redisplay-interface on changes the value-function and ok-check do not
appear to be called ...

	cheers

		Andrew

;---------------------------------------------------------------------
; INTERFACE SHEETS-SEARCH-PRESENTER
;---------------------------------------------------------------------

(define-interface sheet-search-presenter ()
  ()
  (:panes
   (tp-search title-pane :text "Search"
              :visible-min-width 80)
   (tip-search text-input-pane
               :accessor tip-search
               :visible-min-width 160
               :change-callback #'cb-on-change-search)
   (mclp-sheets multi-column-list-panel
                :accessor mlcp-sheets
                :columns '((:title "Title"))
                :selection-callback #'cb-on-selection
                :column-function #'(lambda (sheet) (list (title sheet)))
                :visible-min-height 200))
  (:layouts
   (column-main column-layout '(row-search mclp-sheets))
   (row-search row-layout '(tp-search tip-search)
               :y-adjust :center))
  (:default-initargs
   :layout 'column-main))

;(display (make-instance 'sheet-search-presenter))

(defmethod initialize-instance :after ((ifc sheet-search-presenter) &rest args)
  (set-matching-sheets "" (mlcp-sheets ifc)))

(defun cb-on-change-search (text pane ifc pos)
  (set-matching-sheets (text-input-pane-text (tip-search ifc))
                       (mlcp-sheets ifc))
  (redisplay-interface ifc))

(defun cb-on-selection (data ifc)
  (redisplay-interface ifc))

(defun set-matching-sheets (query pane)
  (let ((matches (loop :for sheet :in (sheets *sheet-db*)
                       :if (matches-query sheet query)
                       :collect sheet)))
    (setf (collection-items pane)
          (if matches
            (make-array (list (length matches)) :initial-contents matches)
            #()))))

;---------------------------------------------------------------------
; POPUP-CONFIRMER SHEET-SEARCH-PRESENTER
;---------------------------------------------------------------------

(defun search-for-sheet ()
  (popup-confirmer (make-instance 'sheet-search-presenter)
                   "Select a sheet"
                   :modal nil
                   :value-function #'sheet-value-function
                   :ok-check #'sheet-ok-check-function))

;; Simply returns the selected item or nil
(defun sheet-value-function (ifc)
  (aif (sel (choice-selected-item (mlcp-sheets ifc)))
       sel nil))

;; Passes through the result of sheet-value-function which should
;; if I've read the manual be enough to change the enabled state
;; of the OK button
(defun sheet-ok-check-function (val)
  (format t "hello")
  val)

;(search-for-sheet)


Re: Frustrations with popup-confirmer

Telepathy.  I was struggling with exactly the same issues 15 minutes 
ago.

One thing that is missing in your code is the second value for 
:value-function.  But I must say that that by itself will probably not 
work as expected yet.

Cheers
--
Marco



On Dec 30, 2005, at 12:26 PM, Andrew Lawson wrote:

>
> Hello all
>     I'd like someone to tell me what stupidity I'm committing with the
> following code. I have a simple interface I want to wrap in a
> popup-confirmer and my implementations for :value-function and
> :ok-check will not enable the OK button. The code below will not
> run on it's own but hopefully it's simple enough for someone to
> spot my error. Note that it appears that although I call
> redisplay-interface on changes the value-function and ok-check do not
> appear to be called ...
>
> 	cheers
>
> 		Andrew
>
> ;---------------------------------------------------------------------
> ; INTERFACE SHEETS-SEARCH-PRESENTER
> ;---------------------------------------------------------------------
>
> (define-interface sheet-search-presenter ()
>   ()
>   (:panes
>    (tp-search title-pane :text "Search"
>               :visible-min-width 80)
>    (tip-search text-input-pane
>                :accessor tip-search
>                :visible-min-width 160
>                :change-callback #'cb-on-change-search)
>    (mclp-sheets multi-column-list-panel
>                 :accessor mlcp-sheets
>                 :columns '((:title "Title"))
>                 :selection-callback #'cb-on-selection
>                 :column-function #'(lambda (sheet) (list (title 
> sheet)))
>                 :visible-min-height 200))
>   (:layouts
>    (column-main column-layout '(row-search mclp-sheets))
>    (row-search row-layout '(tp-search tip-search)
>                :y-adjust :center))
>   (:default-initargs
>    :layout 'column-main))
>
> ;(display (make-instance 'sheet-search-presenter))
>
> (defmethod initialize-instance :after ((ifc sheet-search-presenter) 
> &rest args)
>   (set-matching-sheets "" (mlcp-sheets ifc)))
>
> (defun cb-on-change-search (text pane ifc pos)
>   (set-matching-sheets (text-input-pane-text (tip-search ifc))
>                        (mlcp-sheets ifc))
>   (redisplay-interface ifc))
>
> (defun cb-on-selection (data ifc)
>   (redisplay-interface ifc))
>
> (defun set-matching-sheets (query pane)
>   (let ((matches (loop :for sheet :in (sheets *sheet-db*)
>                        :if (matches-query sheet query)
>                        :collect sheet)))
>     (setf (collection-items pane)
>           (if matches
>             (make-array (list (length matches)) :initial-contents 
> matches)
>             #()))))
>
> ;---------------------------------------------------------------------
> ; POPUP-CONFIRMER SHEET-SEARCH-PRESENTER
> ;---------------------------------------------------------------------
>
> (defun search-for-sheet ()
>   (popup-confirmer (make-instance 'sheet-search-presenter)
>                    "Select a sheet"
>                    :modal nil
>                    :value-function #'sheet-value-function
>                    :ok-check #'sheet-ok-check-function))
>
> ;; Simply returns the selected item or nil
> (defun sheet-value-function (ifc)
>   (aif (sel (choice-selected-item (mlcp-sheets ifc)))
>        sel nil))
>
> ;; Passes through the result of sheet-value-function which should
> ;; if I've read the manual be enough to change the enabled state
> ;; of the OK button
> (defun sheet-ok-check-function (val)
>   (format t "hello")
>   val)
>
> ;(search-for-sheet)
>
--
Marco Antoniotti					http://bioinformatics.nyu.edu/~marcoxa
NYU Courant Bioinformatics Group		tel. +1 - 212 - 998 3488
715 Broadway 10th FL				fax. +1 - 212 - 998 3484
New York, NY, 10003, U.S.A.


Re: Frustrations with popup-confirmer

Unable to parse email body. Email id is 5107

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