[REBOL] Re: VID focus questions
From: dlhawley:attbi at: 11-Feb-2002 15:01
Brett Handley wrote:
>I'm glad you find it useful.
>
>I'd like your mods. If they're not too big, you could post em here but
>otherwise email me directly - thanks!
>
Brett and all,
Attached is my nd-styles.r which is a glom of theseand a few other
things that have been discussed recently. The check and rotary mods work
best. choice and button are somewhat useful, but need more work. I also
included upper/lower fields which were presented in other discussions. I
started on a numeric-field, but haven't done more that lay out some
ideas. I'd like to have a field which takes a format (in user-data?) and
does something reasonable ie:
phone :fmt-field user-data "(###)###-####"
I probably need to dig into ctx-text to make this work....
Dave
-- Attached file included as plaintext by Listar --
-- File: nd-styles.r
REBOL []
do %back-field-fix.r
modified-check-feel:
[ ; Basic highlighting of the checkbox with focus
redraw: function [face action pos] [bvlc cond-c cond-f]
[ cond-c: equal? face/edge/color bvlc: svv/vid-colors/bevel
cond-f: equal? face system/view/focal-face
if equal? cond-c cond-f
[ face/edge/color: either cond-f [black] [bvlc]]
svvf/check/redraw face action pos
]
; Space bar toggles check - tab moves to next tabbed item
engage: func [face action event]
[ either equal? event/type 'key
[ switch event/key
[ #" " [ svvf/check/engage face 'down event ]
#"^-" [ focus either event/shift
[ ctx-text/back-field face ]
[ ctx-text/next-field face ]
]
]
]
[ if equal? event/type 'down [focus face]
svvf/check/engage face action event
]
]
]
modified-choice-feel:
[ ; Basic highlighting of the choice with focus
redraw: function [face action pos] [bvlc cond-c cond-f]
[ cond-c: equal? face/edge/color bvlc: svv/vid-colors/bevel
cond-f: equal? face system/view/focal-face
if equal? cond-c cond-f
[ face/edge/color: either cond-f [black] [bvlc]]
svvf/choice/redraw face action pos
]
; Space bar toggles choice - tab moves to next tabbed item
engage: func [face action event]
[ either equal? event/type 'key
[ switch event/key
[ #" " [ svvf/choice/engage face 'down event
svvf/choice/engage face 'up event
]
#"^-" [ focus either event/shift
[ ctx-text/back-field face ]
[ ctx-text/next-field face ]
]
]
]
[ if equal? event/type 'down [focus face]
svvf/choice/engage face action event
]
]
]
modified-rotary-feel:
[ ; Basic highlighting of the rotary with focus
redraw: function [face action pos] [bvlc cond-c cond-f]
[ cond-c: equal? face/edge/color bvlc: svv/vid-colors/bevel
cond-f: equal? face system/view/focal-face
if equal? cond-c cond-f
[ face/edge/color: either cond-f [black] [bvlc]]
svvf/rotary/redraw face action pos
]
; Space bar toggles - tab moves to next tabbed item
engage: func [face action event]
[ either equal? event/type 'key
[ switch event/key
[ #" " [ svvf/rotary/engage face 'down event
svvf/rotary/engage face 'up event
]
#"^-" [ focus either event/shift
[ ctx-text/back-field face ]
[ ctx-text/next-field face ]
]
]
]
[ if equal? event/type 'down [focus face]
svvf/rotary/engage face action event
]
]
]
modified-button-feel:
[ ; Basic highlighting of the button with focus
redraw: function [face action pos] [bvlc cond-c cond-f]
[ cond-c: equal? face/edge/color bvlc: svv/vid-colors/bevel
cond-f: equal? face system/view/focal-face
if equal? cond-c cond-f
[ face/edge/color: either cond-f [black] [bvlc]]
svvf/button/redraw face action pos
]
; Space bar toggles - tab moves to next tabbed item
engage: func [face action event]
[ either equal? event/type 'key
[ switch event/key
[ #" " [ svvf/button/engage face 'down event
svvf/button/engage face 'up event
]
#"^-" [ focus either event/shift
[ ctx-text/back-field face ]
[ ctx-text/next-field face ]
]
]
]
[ if equal? event/type 'down [focus face]
svvf/button/engage face action event
]
]
]
f-dbg: none
field-fixup: func [fce][
f-dbg: fce
fce/text: fce/user-data/fun fce/text
]
numeric-fixup: make object! [
fun: func [str][
print [ str self/pat]
str
]
pat: none
]
stylize/master [
space-check: check with [
feel: make feel modified-check-feel
flags: [check tabbed]
]
space-choice: choice with [
feel: make feel modified-choice-feel
flags: [choice tabbed]
]
space-rotary: rotary with [
feel: make feel modified-rotary-feel
flags: [rotary tabbed]
]
space-button: button with [
feel: make feel modified-button-feel
flags: [button tabbed]
]
uppercase-field: field with
[ feel: make feel
[ redraw: func first :redraw append
second :redraw [if act = 'show [face/text: uppercase face/text]];'
]
]
lowercase-field: field with
[ feel: make feel
[ redraw: func first :redraw append
second :redraw [if act = 'show [face/text: lowercase face/text]];'
]
]
numeric-field: field with
[ feel: make feel
[ redraw: func first :redraw append
second :redraw [if act = 'show [field-fixup face]];'
]
]
]
nd-styles: stylize
[
nd-info: info with [flags: [field]]
]
style-test: func [][
view layout [
styles nd-styles
my-check1: space-check
my-check2: space-check
uppercase-field
lowercase-field
space-choice data ["AAA" "BBB" "CCC"]
choice data ["AAA" "BBB" "CCC"]
space-rotary data ["AAA" "BBB" "CCC"]
numeric-field user-data make numeric-fixup [pat: "####"]
field
space-button "OK" [print "OK"]
; mr1: space-radio of 'aa
; mr2: space-radio of 'aa
i: nd-info "text"
do [focus my-check2]
]
]
style-test