Hi,
I have a very beginners question about calling a command from a push-button.
It seems that I need to call redisplay-frame-panes in the activate-callback, although this is not necessary if I invoke the command from the interactor.
(button2 push-button :label "incf and call REDISPLAY-FRAME-PANES" :activate-callback (lambda (button) (declare (ignore button)) (com-incf) ;; * (redisplay-frame-panes *application-frame*)))
Is an activation of a push-button not an event in the command-loop?
I would be glad to know, how this is supposed to be done.
Best, Kilian
================================================ My changes to the SUPERAPP:
(in-package :common-lisp-user)
(defpackage "APP" (:use :clim :clim-lisp) (:export "APP-MAIN"))
(in-package :app)
(define-application-frame superapp () ((currrent-number :initform 1 :accessor current-number)) (:pointer-documentation t) (:panes (app :application :height 400 :width 600 :display-function 'display-app) (button push-button :label "incf" :activate-callback (lambda (button) (declare (ignore button)) (com-incf))) (button2 push-button :label "incf and call REDISPLAY-FRAME-PANES" :activate-callback (lambda (button) (declare (ignore button)) (com-incf) (redisplay-frame-panes *application-frame*))) (int :interactor :height 200 :width 600)) (:layouts (default (vertically () (horizontally () +fill+ button button2 +fill+) app int))))
(defun display-app (frame pane) (let ((number (current-number frame))) (format pane "~a is ~a" number (cond ((null number) "not a number") ((oddp number) "odd") (t "even")))))
(defun app-main () (run-frame-top-level (make-application-frame 'superapp)))
(define-superapp-command (com-quit :name t) () (frame-exit *application-frame*))
(define-superapp-command (com-parity :name t) ((number 'integer)) (setf (current-number *application-frame*) number))
(define-superapp-command (com-incf :name t) () (incf (current-number *application-frame*)))
Kilian Sprotte kilian.sprotte@gmail.com writes:
Hi,
I have a very beginners question about calling a command from a push-button.
It seems that I need to call redisplay-frame-panes in the activate-callback, although this is not necessary if I invoke the command from the interactor.
(button2 push-button :label "incf and call REDISPLAY-FRAME-PANES" :activate-callback (lambda (button) (declare (ignore button)) (com-incf) ;; * (redisplay-frame-panes *application-frame*)))
Is an activation of a push-button not an event in the command-loop?
Indeed not, events/callbacks are asynchronous and separate from the command loop.
I would be glad to know, how this is supposed to be done.
Manually redisplaying seems like an adequate solution. If your program is large, or does advanced things with its command loop, you may want to cause callbacks to integrate with it by various means, though.