From c95e546472888bc4e4ce01df87a9124861f22e42 Mon Sep 17 00:00:00 2001 From: William Robinson Date: Sat, 6 Sep 2008 23:32:51 +0100 Subject: [PATCH] Moved focused widget parameter for buildability. Safely igore root-widget on input events. --- src/cowl-input.lisp | 6 ++++++ src/cowl.lisp | 18 ++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/cowl-input.lisp b/src/cowl-input.lisp index 67b14b1..388eb9a 100644 --- a/src/cowl-input.lisp +++ b/src/cowl-input.lisp @@ -6,6 +6,12 @@ with the new string.")) (:documentation "Widget for editable text. ")) +;;; INPUT STATE + +(defparameter *focused-widget* nil + "The currently active input widget. If nil, nothing is currently being edited.") +(declaim (type (or input null) *focused-widget*)) + (defparameter *edit-mode-cursor-positions* (list 0 0) "A list of two values of the current cursor position. If the values are different, diff --git a/src/cowl.lisp b/src/cowl.lisp index 9938108..ef6a573 100644 --- a/src/cowl.lisp +++ b/src/cowl.lisp @@ -28,10 +28,6 @@ this represents the root of the tree. TODO say more") ;;; INPUT STATE -(defparameter *focused-widget* nil - "The currently active input widget. If nil, nothing is currently being edited.") -(declaim (type (or input null) *focused-widget*)) - (defparameter *ignore-events* nil "This must be set to T before any event processing is done. The reason this is here is to prevent superfluous events from @@ -147,9 +143,10 @@ if they are unspecified, the last value given to mouse-motion-event will be used (unless (some #'(lambda (h) (funcall h button press x y)) *mouse-button-handlers*) - (handle-mouse-button *root-widget* button press - (- x (current-offset-of (x *root-widget*))) - (- y (current-offset-of (y *root-widget*))))))) + (when *root-widget* + (handle-mouse-button *root-widget* button press + (- x (current-offset-of (x *root-widget*))) + (- y (current-offset-of (y *root-widget*)))))))) (defun mouse-wheel-event (zrel &optional (x (car *prev-mouse*)) (y (cdr *prev-mouse*))) "Send a new wheel event. zrel is the difference from the last event of the @@ -162,9 +159,10 @@ if they are unspecified, the last value given to mouse-motion-event will be used (unless (some #'(lambda (h) (funcall h zrel x y)) *mouse-motion-handlers*) - (handle-mouse-wheel *root-widget* zrel - (- x (current-offset-of (x *root-widget*))) - (- y (current-offset-of (y *root-widget*))))))) + (when *root-widget* + (handle-mouse-wheel *root-widget* zrel + (- x (current-offset-of (x *root-widget*))) + (- y (current-offset-of (y *root-widget*)))))))) (defun mouse-motion-event (x y) "Send a new mouse position into Cowl. -- 2.11.4.GIT