VID focus questions
[1/18] from: dlhawley::attbi::com at: 30-Jan-2002 21:12
How does one do the following:
1: give focus to a check, choice, button
2: keep focus off of an info or list
3: make radio's non-exclusive
4: make a choice keycode pickable
I have a layout with fields which tab OK, then the cursor gets stuck in
an info field and one has to mouse to get to check and button fields.
Shouldn't tab normally just go to the next thing? And shouldn't an info
be totaly ignored?
note: View on WinMe
Thanks,
Dave
[2/18] from: dlhawley:attbi at: 4-Feb-2002 14:20
Any ideas on this anyone?
David Hawley wrote:
[3/18] from: philb:upnaway at: 5-Feb-2002 15:23
Hi Dave,
for problem 2 use could use the code Sterlings posted a few days ago ....
for example
view layout [
field
field
info with [flags: [field]]
field
]
Now you cant tab into the info item.
On a related question what stops shift & tab working in the following code ....
view layout [
field "AAA"
field "BBB"
field "CCC"
]
Tabbing between the fields works.
When you shift tab out of anything other than the first field that works.
But why cant you shift tab out of the first field, positioning you in the last field??
Cheers Phil
=== Original Message ===
Any ideas on this anyone?
David Hawley wrote:
[4/18] from: cybarite:sympatico:ca at: 4-Feb-2002 21:14
For #3, if I understand what you want,
radio of 'word allows you to have groups of radio buttons
across backtile polished
radio of 'programming-language pad 0x-4 label "Language: REBOL" return
radio of 'programming-language pad 0x-4 label "Language: C++" return
radio of 'editor pad 0x-4 label "Editor: TextPad" return
radio of 'editor pad 0x-4 label "Editor: Notepad" return
[5/18] from: brett:codeconscious at: 6-Feb-2002 1:09
Hi David,
> > How does one do the following:
> >
> > 1: give focus to a check, choice, button
> > 2: keep focus off of an info or list
> > 3: make radio's non-exclusive
> > 4: make a choice keycode pickable
I see you have replies to 2 and 3 so I'll make reply to 1.
Focus can be set with the FOCUS function:
view layout [
my-check: check
do [focus my-check]
]
However, a check doesn't look like it is focussed. Maybe the redraw function
for the check and the other styles need amendment.
I'm sipping on some wine, so it has probably affected my priorities! Instead
of addressing the visual aspect of focussing
I got involved with what happens if you hit the space bar. In Windows doing
so when a check box is focussed will toggle
the check box off and on. So this is what I've done with this next bit of
code:
view layout [
my-check: check
do [my-check/feel: make my-check/feel [
engage: func [face action event] [
either all [equal? event/type 'key equal? event/key #" "] [
system/view/vid/vid-feel/check/engage face 'down event
] [
system/view/vid/vid-feel/check/engage face action event
]
]
]
]
do [focus my-check]
]
In essence I've replaced the feel for the check box with a modified version.
In the modified version the engage function is redefined to trap the space
bar keystroke. If a space keystoke is detected, a simulated mouse down call
is made to the original engage function. Other calls to engage are routed to
the original functionality.
Now I shoudl sleep off this nice wine :)
I hope this helps *and* is relevant!
Brett
[6/18] from: dlhawley:attbi at: 5-Feb-2002 10:25
Yes,
Exactly - is this documented? I've read the view developers guide a
bunch of times and missed this.
Dave
cybarite wrote:
[7/18] from: dlhawley:attbi at: 5-Feb-2002 11:09
Phil,
Thanks the info with... works great. I just don't understand why that
isn't the default or where to figure this out from documentation. Also,
unless you add the with, you can't tab out of the info... Just dosn't
make sense for what I see an info used for.
On our second example - that works, but what does not is if I put a
choice, check or similar item in between the fields. I'll look a other
replies before going further.
Dave
[philb--upnaway--com] wrote:
[8/18] from: brett:codeconscious at: 6-Feb-2002 19:50
Hi David,
> Thanks the info with... works great. I just don't understand why ...
Your comments are probably worthwhile feedback material.
Brett
[9/18] from: dlhawley:attbi at: 6-Feb-2002 15:12
Brett,
I still can't get focus to work on check except in the case of a do [
focus my-check ]
and then only on the first check. I liked your space key to turn check
on/off and tried to generalize as follows:
stylize/master
[ space-check: check with [ feel: make feel
[engage: func [face action event]
[ either all [equal? event/type 'key equal? event/key #" "]
[ system/view/vid/vid-feel/check/engage face 'down event]
[ system/view/vid/vid-feel/check/engage face action event]
]
]
]
]
view layout [
my-check1: space-check
my-check2: space-check
]
The first space-check works as expected, but when I move the mouse over
the second, click it on-off a few times, the first still gets toggled
when I click the space key.
Any ideas on what I'm doing wrong?
Brett Handley wrote:
[10/18] from: dlhawley:attbi at: 5-Feb-2002 14:29
Brett,
This works nicely for one check, but when I tried to expand it for
multiple ones I got stuck. I tried to put your do [my-check/feel ...
info a block of
feels: [ space-check [<what goes here>/feel: make <what goes here>/feel ...
with the idea that I could do something like
mc1: check do feels/space-check
mc2: check do feels/space-check
better would be to make a style space-check but am having trouble
generalizing this also.
Got any ideas on how to do this?
Also, still having trouble with passing focus onto multiple checks,
radios, choice and so on.
Dave
Brett Handley wrote:
>Hi David,
>>>How does one do the following:
<<quoted lines omitted: 40>>
>I hope this helps *and* is relevant!
>Brett
--
David L. Hawley D.L. Hawley and Associates 1.503.274.2242
Software Engineer [David--L--Hawley--computer--org]
[11/18] from: dlhawley:attbi at: 6-Feb-2002 20:04
Actually, on further research, it appears that this scheme only works
when hte check is given focus with a [ do focus] - if focus is moves to
say a field, then there is no way to click on the check and get the
space
focus back to it.I'm confused. This really shouldn't be that
hard in a system that's designed for non programmers to make use of.
Dave
David Hawley wrote:
[12/18] from: brett:codeconscious at: 7-Feb-2002 22:12
Hi Dave,
> Actually, on further research, it appears that this scheme only works
> when hte check is given focus with a [ do focus] - if focus is moves to
> say a field, then there is no way to click on the check and get the
> "space" focus back to it.
Fixed that now.
> I'm confused. This really shouldn't be that
> hard in a system that's designed for non programmers to make use of.
I think this sort of feature is important, because it is has a long
tradition
in GUIs. VID is a remarkably small GUI framework and I believe RT
will evolve these sort of features in VID over time. Or someone else
will produce a framework that satisfies the standard features list.
A work in progress I guess.
Back to the code.
I've worked out now that by testing for mouse down I can set the focus.
I went on provide tabbing between multiple checkboxes.
For bonus marks, I tried highlighting which checkbox actually has focus.
I haven't thought about how to apply such findings to other styles.
I also don't know if I've broken any VID rules, so I don't know
how or whether it can be applied more generally.
But maybe it is a couple of steps closer.
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
]
]
]
stylize/master [
space-check: check with [
feel: make feel modified-check-feel
flags: [check tabbed]
]
]
view layout [
across
space-check [print "action test first check"]
space-check space-check space-check return
field
]
Regards,
Brett
[13/18] from: dlhawley:attbi at: 7-Feb-2002 14:51
Brett,
This is great. I've been able to modify the example for rotary (works as
expected) choice (need to use up/down arrows next!) and buttons (not
much feedback yet on space engage) I just changed the svvf/<choice>/...
to rotary, choice, button and
had to add an 'up event on the #" " switch.
One problem is that the ctx-txt/back-field gets lost when you back tab
off of the first face. next-field wraps properly.
A lot of it is still a mystery, but maybe some of this behavior can be
made part of the defaults some day.
Let me know if anyone wants to see my mods.
Dave
Brett Handley wrote:
[14/18] from: brett:codeconscious at: 8-Feb-2002 16:34
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!
I noticed the back-field problem too, but it only occurs if the check box is
first in the face, put a text in front
of it and there is no problem. I guess the code for back-field has a slight
bug. The code is very small so a fix should be easy.
[15/18] from: brett:codeconscious at: 8-Feb-2002 19:39
I wrote:
> I noticed the back-field problem too, but it only occurs if the check box
is
> first in the face, put a text in front
> of it and there is no problem. I guess the code for back-field has a
slight
> bug. The code is very small so a fix should be easy.
I've made a fix (will send it to feedback as well):
if 6939838 = checksum mold get in ctx-text 'back-field [
print "ctx-text/back-field fix applied."
set in ctx-text 'back-field func [face /local item] [
all [
item: find face/parent-face/pane face
while [
if head? item [item: tail item]
face <> first (item: back item)
] [
if all [object? item/1 flag-face? item/1 tabbed] [return
item/1]
]
]
none
]
]
Regards,
Brett.
[16/18] from: brett:codeconscious at: 8-Feb-2002 20:11
Duh! Sorry for this extra post - my last post had a working function but
stuffed up checksum.
Brett.
[17/18] 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
[18/18] from: brett:codeconscious at: 12-Feb-2002 11:25
Thanks for the code Dave.
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted