Focus and Blur events for windows

This commit is contained in:
David Botton 2021-02-17 17:16:22 -05:00
parent bfdd90d42e
commit c1b6da0b5d
3 changed files with 50 additions and 2 deletions

View file

@ -376,6 +376,8 @@ The on-window-change clog-obj received is the new window"))
(defmethod fire-on-window-change (obj app)
"Fire handler if set. Change the value of current-win to clog-obj (Private)"
(when (current-win app)
(fire-on-window-blurred (current-win app)))
(unless obj
(let (new-order
(order -9999))
@ -388,7 +390,8 @@ The on-window-change clog-obj received is the new window"))
(windows app))))
(setf (current-win app) obj)
(when (on-window-change app)
(funcall (on-window-change app) obj)))
(funcall (on-window-change app) obj))
(fire-on-window-focused obj))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - Individual Windows
@ -446,6 +449,14 @@ The on-window-change clog-obj received is the new window"))
:accessor on-window-can-size
:initform nil
:documentation "Return t to allow close of window")
(on-window-focused
:accessor on-window-focused
:initform nil
:documentation "Fired on window focused")
(on-window-blurred
:accessor on-window-blurred
:initform nil
:documentation "Fired on window blurred")
(on-window-close
:accessor on-window-close
:initform nil
@ -839,7 +850,41 @@ interactions. Use window-end-modal to undo."))
(setf (height obj)
(- (inner-height (window (body app))) (menu-bar-height obj)))))
(fire-on-window-size-done obj)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set-on-window-focused ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgeneric set-on-window-focused (clog-gui-window handler)
(:documentation "Set the on-window-focused HANDLER"))
(defmethod set-on-window-focused ((obj clog-gui-window) handler)
(setf (on-window-focused obj) handler))
(defgeneric fire-on-window-focused (clog-gui-window)
(:documentation "Fire handler if set. (Private)"))
(defmethod fire-on-window-focused ((obj clog-gui-window))
(when (on-window-focused obj)
(funcall (on-window-focused obj) obj)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set-on-window-blurred ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgeneric set-on-window-blurred (clog-gui-window handler)
(:documentation "Set the on-window-blurred HANDLER"))
(defmethod set-on-window-blurred ((obj clog-gui-window) handler)
(setf (on-window-blurred obj) handler))
(defgeneric fire-on-window-blurred (clog-gui-window)
(:documentation "Fire handler if set. (Private)"))
(defmethod fire-on-window-blurred ((obj clog-gui-window))
(when (on-window-blurred obj)
(funcall (on-window-blurred obj) obj)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set-on-window-can-close ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;