add accept-tab-focus to editor-canvas%

svn: r17929
This commit is contained in:
Matthew Flatt 2010-02-01 19:30:59 +00:00
parent 102b03311e
commit 09ef762e3f
8 changed files with 67 additions and 47 deletions

View File

@ -946,6 +946,8 @@
(send t auto-wrap #t)
(send t lock #t)
(send c accept-tab-focus #f)
(send c allow-tab-exit #t)
c))
(define (size-discussion-canvas canvas)

View File

@ -260,6 +260,10 @@
[(on?) (set! force-focus? (and on? #t))
(send wx force-display-focus on?)]))]
[accept-tab-focus (entry-point
(case-lambda
[() (send wx get-tab-focus)]
[(on?) (send wx set-tab-focus (and on? #t))]))]
[allow-tab-exit (entry-point
(case-lambda
[() (send wx is-tabable?)]

View File

@ -14,7 +14,7 @@
wx-canvas%
wx-editor-canvas%))
(define (make-canvas-glue% %) ; implies make-window-glue%
(define (make-canvas-glue% default-tabable? %) ; implies make-window-glue%
(class100 (make-window-glue% %) (mred proxy . args)
(inherit get-mred get-top-level clear-margins)
(public
@ -22,6 +22,22 @@
[do-on-event (lambda (e) (super on-event e))]
[do-on-scroll (lambda (e) (super on-scroll e))]
[do-on-paint (lambda () (super on-paint))])
(private-field
[tabable? default-tabable?])
(public
[get-tab-focus (lambda () tabable?)]
[set-tab-focus (lambda (v) (set! tabable? v))]
[on-tab-in (lambda ()
(let ([mred (wx->mred this)])
(when mred
(send mred on-tab-in))))])
(override
[gets-focus? (lambda () tabable?)]
[handles-key-code
(lambda (code alpha? meta?)
(if default-tabable?
(super handles-key-code code alpha? meta?)
(or meta? (not tabable?))))])
(private
[clear-and-on-paint
(lambda (mred)
@ -68,20 +84,11 @@
(define wx-canvas%
(make-canvas-glue%
#f
(class100 (make-control% wx:canvas% 0 0 #t #t) (parent x y w h style gl-config)
(inherit get-top-level)
(private-field
[tabable? #f])
(public
[clear-margins (lambda () (void))]
[on-tab-in (lambda () (send (wx->mred this) on-tab-in))]
[get-tab-focus (lambda () tabable?)]
[set-tab-focus (lambda (v) (set! tabable? v))])
(override
[gets-focus? (lambda () tabable?)]
[handles-key-code
(lambda (code alpha? meta?)
(or meta? (not tabable?)))])
[clear-margins (lambda () (void))])
(sequence
(super-init style parent x y w h (cons 'deleted style) "canvas" gl-config)
(unless (memq 'deleted style)
@ -163,10 +170,6 @@
(public
[set-tabable (lambda (on?) (set! tabable? on?))]
[is-tabable? (lambda () tabable?)]
[on-tab-in (lambda ()
(let ([mred (wx->mred this)])
(when mred
(send mred on-tab-in))))]
[set-single-line (lambda () (set! single-line-canvas? #t))]
[is-single-line? (lambda () single-line-canvas?)]
[set-line-count (lambda (n)
@ -220,6 +223,7 @@
(define wx-editor-canvas%
(class (make-canvas-glue%
#t
(make-editor-canvas% (make-control% wx:editor-canvas%
0 0 #t #t)))
(inherit editor-canvas-on-scroll)

View File

@ -90,26 +90,6 @@ The @scheme[gl-config] argument determines properties of an OpenGL
}
@defmethod*[([(accept-tab-focus)
boolean?]
[(accept-tab-focus [on? any/c])
void?])]{
@index['("keyboard focus" "navigation")]{Gets} or sets whether
tab-focus is enabled for the canvas (assuming that the canvas is
not created with the @scheme['no-focus] style). When tab-focus is
enabled, the canvas can receive the keyboard focus when the user
navigates among a frame or dialog's controls with the Tab and
arrow keys. By default, tab-focus is disabled.
When tab-focus is enabled for a canvas, Tab, arrow, and Enter keyboard
events are consumed by a frame's default
@method[top-level-window<%> on-traverse-char] method. (In addition, a dialog's default method consumes Escape key
events.) Otherwise,
@method[top-level-window<%> on-traverse-char] allows the keyboard events to be propagated to the canvas.
}
@defmethod[(get-scroll-page [which (one-of/c 'horizontal 'vertical)])
(integer-in 1 1000000000)]{

View File

@ -21,6 +21,33 @@ The @scheme[canvas<%>] interface is implemented by two classes:
]
@defmethod*[([(accept-tab-focus)
boolean?]
[(accept-tab-focus [on? any/c])
void?])]{
@index['("keyboard focus" "navigation")]{Gets} or sets whether
tab-focus is enabled for the canvas (assuming that the canvas is
not created with the @scheme['no-focus] style for @scheme[canvas%]). When tab-focus is
enabled, the canvas can receive the keyboard focus when the user
navigates among a frame or dialog's controls with the Tab and
arrow keys. By default, tab-focus is disabled.
When tab-focus is enabled for a @scheme[canvas%] object, Tab, arrow,
Enter, and Escape keyboard events are consumed by a frame's default
@method[top-level-window<%> on-traverse-char] method. (In addition, a
dialog's default method consumes Escape key events.) Otherwise,
@method[top-level-window<%> on-traverse-char] allows the keyboard
events to be propagated to the canvas.
For an @scheme[editor-canvas%] object, handling of Tab, arrow, Enter,
and Escape keyboard events is determined by the
@method[editor-canvas% allow-tab-exit] method.
}
@defmethod[(get-canvas-background)
(or/c (is-a?/c color%) false/c)]{
Returns the color currently used to ``erase'' the canvas content before
@ -144,7 +171,7 @@ Called when the keyboard focus enters the canvas via keyboard
@method[window<%> on-focus] is called.
See also
@xmethod[canvas% accept-tab-focus] and
@method[canvas<%> accept-tab-focus] and
@xmethod[top-level-window<%> on-traverse-char] .
}

View File

@ -121,15 +121,16 @@ Enables or disables last-line scrolling, or gets the current enable
@index['("keyboard focus" "navigation")]{Gets} or sets whether
tab-exit is enabled for the editor canvas. When tab-exit is enabled,
the user can move the keyboard focus out of the editor using the Tab
and arrow keys, or invoke the default button using the Enter/Return
key. By default, tab-exit is disabled.
and arrow keys, invoke the default button using the Enter/Return key,
or invoke a dialog's close action with Escape. By default, tab-exit
is disabled.
When tab-exit is enabled for an editor canvas, Tab, arrow, and Enter
keyboard events are consumed by a frame's default
@method[top-level-window<%> on-traverse-char] method. (In addition, a
dialog's default method consumes Escape key events.) Otherwise,
@method[top-level-window<%> on-traverse-char] allows the keyboard
events to be propagated to the canvas.
When tab-exit is enabled for an editor canvas, Tab and Enter keyboard
events are consumed by a frame's default @method[top-level-window<%>
on-traverse-char] method; in addition, a dialog's default method
consumes Escape key events. Otherwise, @method[top-level-window<%>
on-traverse-char] allows the keyboard events to be propagated to the
canvas.
}

View File

@ -223,7 +223,7 @@ If the window that currently owns the focus specifically handles the
Meta/Alt events.}
@item{@scheme[canvas%] --- when tab-focus is disabled (see
@method[canvas% accept-tab-focus]): all keyboard events, except alphanumeric key events when the Meta
@method[canvas<%> accept-tab-focus]): all keyboard events, except alphanumeric key events when the Meta
(X) or Alt (Windows) key is pressed; when tab-focus is enabled:
no key events}

View File

@ -1,5 +1,7 @@
Version 4.2.4.1
Version 4.2.4.2
Added accept-tab-focus method to canvas<%> and editor-canvas%
Version 4.2.4.1
Changed radio-box% to allow #f as a selection so that no buttons are
selected