From 6d1824019f7ee0edc7fa1574041fc8e1871fee9d Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 16 Dec 2013 07:14:35 -0700 Subject: [PATCH] fixes for keyboard navigation and tab panels The geometry used for keyboard navigation and tab-panel% instances was wrong. That problem, in turn, exposed a potential infinite loop in the function that computes the next tab position (when geometries overlap). Fix both. Closes PR 14255 Merge to v6.0 original commit: 37dd4fc2b0023d710e7e4d8c4fe35af67de326d3 --- pkgs/gui-pkgs/gui-lib/mred/private/helper.rkt | 16 +++++++++++----- pkgs/gui-pkgs/gui-lib/mred/private/wxpanel.rkt | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pkgs/gui-pkgs/gui-lib/mred/private/helper.rkt b/pkgs/gui-pkgs/gui-lib/mred/private/helper.rkt index 837633ef..21192ef3 100644 --- a/pkgs/gui-pkgs/gui-lib/mred/private/helper.rkt +++ b/pkgs/gui-pkgs/gui-lib/mred/private/helper.rkt @@ -196,7 +196,7 @@ (< (caar s) (cdr best))))) (loop (cdr s) (car s))] [else (loop (cdr s) best)])))] - [find (lambda (get-x get-w get-y get-h use-x? x w use-y? y h dests fail) + [find (lambda (v? get-x get-w get-y get-h use-x? x w use-y? y h dests fail) ;; find's variable names correspond to an h-stripe view, but everything is ;; flipped to v-stripes if the args are flipped (let ([h-stripes (mk-stripes get-y get-h @@ -223,7 +223,13 @@ (next) ;; Non-empty h-stripe; now look for items in the same or later v-stripe - (if (null? (cdr in-init-h-stripe)) + (if (or (null? (cdr in-init-h-stripe)) + ;; If we're already in "v-stripe" mode, then flipping back + ;; to h-stripe mode is going to loop forever, so treat the + ;; current strip as having only one item. (This should + ;; happen only if the start positions overlap with the + ;; destination positions.) + v?) ;; one item in the stripe; take it unless we're using x and it's ;; before x: @@ -235,12 +241,12 @@ (next)) ;; Recur to work with v-stripes - (find get-y get-h get-x get-w use-y? y h use-x? x w in-init-h-stripe next)))))))]) + (find #t get-y get-h get-x get-w use-y? y h use-x? x w in-init-h-stripe next)))))))]) (if (null? dests) #f - (car (find get-x get-w get-y get-h #t x w #t y h dests + (car (find #f get-x get-w get-y get-h #t x w #t y h dests (lambda () - (find get-x get-w get-y get-h + (find #f get-x get-w get-y get-h #f fail-start fail-start #f fail-start fail-start dests void))))))] diff --git a/pkgs/gui-pkgs/gui-lib/mred/private/wxpanel.rkt b/pkgs/gui-pkgs/gui-lib/mred/private/wxpanel.rkt index e37bc346..213ad7f4 100644 --- a/pkgs/gui-pkgs/gui-lib/mred/private/wxpanel.rkt +++ b/pkgs/gui-pkgs/gui-lib/mred/private/wxpanel.rkt @@ -830,8 +830,8 @@ (inherit gets-focus?) (super-new) (define/override (tabbing-position x y w h) - ;; claim that the panel is short: - (list this x y w 16)) + ;; claim that the panel is short and starts above its client area: + (list this x (- y 16) w 16)) (define/override (focus-on-self?) (gets-focus?)))) (define wx-panel% (wx-make-panel% wx:panel%))