Changeset 7347


Ignore:
Timestamp:
Oct 4, 2007, 3:02:08 PM (12 years ago)
Author:
af
Message:

Initial work on an interface to selections in text fields.

NB: Not entirely working yet.

Location:
branches/easygui/ccl/examples/cocoa/easygui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/easygui/ccl/examples/cocoa/easygui/new-cocoa-bindings.lisp

    r7325 r7347  
    99  (assert (>= y 0))
    1010  (make-instance 'eg-point :x x :y y))
     11
     12(defclass eg-range ()
     13     ((start :initarg :start :reader range-start)
     14      (end :initarg :end :reader range-end)))
     15
     16(defun range (start end)
     17  (assert (>= end start))
     18  (make-instance 'eg-range :start start :end end))
     19
     20(defun range-nsrange (range)
     21  (ns:make-ns-range (range-start range) (range-end range)))
    1122
    1223(defclass easy-cocoa-object ()
  • branches/easygui/ccl/examples/cocoa/easygui/package.lisp

    r7346 r7347  
    22  (:use :cl)
    33  (:import-from :ccl with-autorelease-pool @selector lisp-string-from-nsstring +null-ptr+)
    4   (:export #:point #:window
     4  (:export #:point #:range #:window
    55           ;; view classes
    66           #:view #:static-text-view #:text-input-view #:password-input-view
     
    1111           #:initialize-view #:action #:view-text
    1212           #:add-entry #:add-entries #:editable-p
    13            #:entry-text #:nth-cell))
     13           #:entry-text #:nth-cell #:selection))
    1414
    1515(cl:defpackage :easygui-user
  • branches/easygui/ccl/examples/cocoa/easygui/views.lisp

    r7346 r7347  
    4444  (check-type editable-p boolean)
    4545  (dcc (#/setEditable: (cocoa-ref view) editable-p)))
     46
     47(defclass one-selection-mixin () ())
     48
     49(defmethod (setf selection) (selection (view one-selection-mixin))
     50  (dcc (#/setSelectedRange: (cocoa-ref view) (range-nsrange selection))))
     51
     52(defmethod selection ((view one-selection-mixin))
     53  (let ((range (dcc (#/selectedRange (cocoa-ref view)))))
     54    (if (= (ns:ns-range-location range) #$NSNotFound)
     55        nil
     56        (range (ns:ns-range-location range)
     57               (ns:ns-range-length range)))))
    4658
    4759;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     
    6678(defclass static-text-view (view view-text-via-stringvalue-mixin) ())
    6779
    68 (defclass text-input-view (view editable-mixin view-text-via-stringvalue-mixin)
     80(defclass text-input-view (view editable-mixin view-text-via-stringvalue-mixin
     81                                ;; XXX: requires NSTextView, but this is an
     82                                ;; NSTextField:
     83                                #+not-yet one-selection-mixin)
    6984     ((input-locked-p :initform nil :initarg :input-locked-p
    7085                      :reader text-input-locked-p)))
Note: See TracChangeset for help on using the changeset viewer.