Changeset 14244


Ignore:
Timestamp:
Sep 10, 2010, 5:14:54 PM (9 years ago)
Author:
rme
Message:

Rename shift-key-p to shift-key-now-p. Remove other related functinons
(control-key-p, etc.) that are not the appropriate way to test for
keystroke modifiers during event processing.

These functions are/were implemented in a way that checks the
instantaneous state of the keyboard. Sometimes this is needed,
but when handling events normally, one would use something like:

(let ((event (#/currentEvent *NSApp*)))

(logtest (#/modifierFlags event) #$NSShiftKeyMask)
...)

Location:
trunk/source/cocoa-ide
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/app-delegate.lisp

    r14225 r14244  
    5959  (declare (ignore notification))
    6060  (initialize-user-interface)
    61   (unless (shift-key-p)
     61  (unless (shift-key-now-p)
    6262    (load-ide-init-file)))
    6363
  • trunk/source/cocoa-ide/cocoa-utils.lisp

    r14241 r14244  
    412412
    413413
    414 ;;; This stuff is not Cocoa-specific.
     414;; This works even if an event loop is not running.
    415415
    416416#+windows-target
    417 (progn
    418 (defun caps-lock-key-p ()
    419   ;; I thought this might work, but it seems to behave oddly.
    420   ;;(logbitp 0 (#_GetAsyncKeyState #$VK_CAPITAL))
    421   nil)
    422 
    423 (defun shift-key-p ()
     417(defun shift-key-now-p ()
    424418  (logbitp 15 (#_GetAsyncKeyState #$VK_SHIFT)))
    425419
    426 (defun control-key-p ()
    427   (logbitp 15 (#_GetAsyncKeyState #$VK_CONTROL)))
    428 
    429 (defun command-key-p ()
    430   nil)
    431 
    432 (defun option-key-p ()
    433   (logbitp 15 (#_GetAsyncKeyState #$VK_MENU)))
    434 
    435 (defun alt-key-p ()
    436   (option-key-p))
    437 )
    438 
    439420#+darwin-target
    440 (progn
    441 
    442 ;; This works even if an event loop is not running.
    443 (defun cgevent-flags-test (mask)
    444   (require-type mask '(unsigned-byte 64))
     421(defun shift-key-now-p ()
    445422  (let* ((event (#_CGEventCreate +null-ptr+))
    446423         (flags (#_CGEventGetFlags event)))
    447424    (prog1
    448         (logtest flags mask)
     425        (logtest flags #$kCGEventFlagMaskShift)
    449426      (#_CFRelease event))))
    450 
    451 (defun caps-lock-key-p ()
    452   (cgevent-flags-test #$kCGEventFlagMaskAlphaShift))
    453 
    454 (defun shift-key-p ()
    455   (cgevent-flags-test #$kCGEventFlagMaskShift))
    456 
    457 (defun control-key-p ()
    458   (cgevent-flags-test #$kCGEventFlagMaskControl))
    459 
    460 (defun command-key-p ()
    461   (cgevent-flags-test #$kCGEventFlagMaskCommand))
    462 
    463 (defun option-key-p ()
    464   (cgevent-flags-test #$kCGEventFlagMaskAlternate))
    465 
    466 (defun alt-key-p ()
    467   (option-key-p))
    468 )
  • trunk/source/cocoa-ide/start.lisp

    r14225 r14244  
    8282
    8383(defmethod ccl::application-init-file ((a cocoa-application))
    84   (unless (shift-key-p)
     84  (unless (shift-key-now-p)
    8585    '("home:ccl-init" "home:\\.ccl-init")))
    8686
Note: See TracChangeset for help on using the changeset viewer.