I'm currently learning McCLIM. Trying to figure out how to define a command, that will react to keystroke. For a app named superapp
I have a function
(defun show (text)
(lambda (gadget)
(declare (ignore gadget))
(with-slots (text-field) *application-frame*
(setf (gadget-value text-field)
text))))
which show some text on it's screen pane. It works fine for pane-buttons in activate-callback
. However, this
(define-superapp-command (com-greet :name t :keystroke (#\g :control)) ()
(show "Hey"))
doesn't work. I know that I defined it right, since it works well with (frame-exit *application-frame*)
. So I just don't understand something else.
EDIT: SO, this is the working variant
(define-application-frame superapp ()
()
(:panes
(tf1
:push-button
:label "Left"
:activate-callback (show "HI"))
(app :application
:display-time nil
:height 400
:width 600)
(screen :text-field))
(:layouts
(default
(with-slots (text-field) *application-frame*
(vertically ()
screen
(tabling (:grid t)
(list tf1 app)))))))
(defun show (text)
(lambda (gadget)
(declare (ignore gadget))
(setf (gadget-value (find-pane-named *application-frame* 'screen))
text)))
(define-superapp-command (com-greet :name t :keystroke (#\g)) ()
(setf (gadget-value (find-pane-named *application-frame* 'screen))
"text"))
In above function you try to get a gadget from a slot. This is not the way to do. Use FIND-PANE-NAMED instead. Give it a frame and the name of the pane. It will return that PANE.
Again, you now use SHOW in a totally different context. Now it SHOULD return a LAMBDA, which gets the gadget as an argument.
Now the code in
:layouts
looks wrong. You should not set the slot text-field in there. Actually you should not have a slot TEXT-FIELD at all. Just use in your call back the function FIND-PANE-NAMED. Here you just define a layout.