Question about APPLY-IN-PANE-PROCRESS
Hi! I recently needed a text input pane that can verify its input when the focus leaves the pane. Luckily, I found an implementation of such a thing which was posted here a while ago by "lisptracker" - thanks. The slightly modified code for my version is below. This works fine. However, I first tried with a simpler version which didn't have a HAS-FOCUS-P slot and where the call to PROCESS-WAIT looked like this: (mp:process-wait "Waiting for blur event" #'(lambda () (not (capi:pane-has-focus-p pane)))) To my surprise this didn't work as expected. Now I'm wondering why the call to APPLY-IN-PANE-PROCESS makes a difference here. According to the Reference Manual it is required when the function "modifies [the] pane or changes how it is displayed." But this doesn't happen here. Any ideas? Thanks, Edi. (defclass verified-text-input-pane (capi:text-input-pane) ((waitingp :initform nil :accessor waitingp) (has-focus-p :initform nil :accessor has-focus-p) (verify-callback :initform nil :initarg :verify-callback :accessor verify-callback))) (defmethod initialize-instance :after ((pane verified-text-input-pane) &rest initargs) (declare (ignore initargs)) (when-let (verify-callback (verify-callback pane)) (let ((old-change-callback (capi:text-input-pane-change-callback pane))) (setf (capi:text-input-pane-change-callback pane) (lambda (&rest args) (unless (waitingp pane) (setf (waitingp pane) t (has-focus-p pane) t) (mp:process-run-function "Guard for VERIFIED-TEXT-INPUT-PANE" '(:priority 0) (lambda () (mp:process-wait "Waiting for blur event" #'(lambda () (capi:apply-in-pane-process pane (lambda () (setf (has-focus-p pane) (capi:pane-has-focus-p pane)))) (not (has-focus-p pane)))) (funcall verify-callback pane) (setf (waitingp pane) nil)))) (when old-change-callback (apply old-change-callback args)))))))