|
Pages: [1]
|
 |
|
Author
|
Topic: Changing focus between faces (Read 708 times)
|
|
jfdutcher
|
The 'marvelous' function below is called with this code which is, at any point, setting on the last character in one of the (7) faces (num1-num7)....the hoped for result is to move the cursor/focus to the next face prior to the 'next' character keyed being displayed. Actually, it has no effect at all.............??
<pre> if all [(face/max-len > 0) (length? face/text) >= face/max-len] [focus-change face exit]
******************************************* focus-change: func [face][ switch face [ 'num1 [focus num2] 'num2 [focus num3] 'num3 [focus num4] 'num4 [focus num5] 'num5 [focus num6] 'num6 [focus num7] 'num7 [focus num1] ] return ] </pre>
|
|
|
|
|
Logged
|
|
|
|
|
Sunanda
|
Problem looks like face is an object, so you can't identify it with a name like if face = 'num1 Here's one way to what you want.....It creates a table of the face objects. Then the button cycles around them. (Note the view/new .... do-events. We need a gap between creating the layout and viewing it so we can create the focus cycling table) unview/all
view/new layout [ f1: field f2: field f3: field button "switch" [ focus focus-table/2 append focus-table focus-table/1;; copy first to end alter focus-table focus-table/1;; remove first ] ]
focus-table: reduce [f1 f2 f3]
do-events
|
|
|
|
|
Logged
|
|
|
|
|
Gabriele
|
view layout [ field field field button "Switch" [ if system/view/focal-face [ focus ctx-text/next-field system/view/focal-face ] ] ]
|
|
|
|
|
Logged
|
|
|
|
|
jfdutcher
|
<pre> You guys reveal real knowledge as the suggestions cause the focus to move to the 'next' field upon keying the 1st character that exceeds the maximum allowed number of characters.
I try to match the 'HTML/Javascript' mirror of the code, which does the focus change...but also records the character that was keyed...and caused focus change to occur....in the field where new focus now lies(as desired).
The code below trys to do this...however though the 'triggering' character changes focus and then 'allows' characters to be recorded in the new field (another key stroke is required) ...the 'triggerng' character itself remains unseen in any field...until you use the 'tab' key to tab to 'any' field. Then the 'triggering' character that caused focus change asserts itself, and shows as an 'extra' (beyond maximum allowed) character in every field where entry took place and which was exited via field '> face/max-len'.
********************************************** if all [(face/max-len > 0) (length? face/text) >= face/max-len] [focus-change ctx-text/edit/engage face action event exit] ********************************************* focus-change: func [][ if system/view/focal-face [ focus ctx-text/next-field system/view/focal-face ] return ********************************************* </pre>
|
|
|
|
|
Logged
|
|
|
|
|
jfdutcher
|
<pre> I'm mildly surprised that this updated attempt to accomplish...doesn't work...instead it records 'two' characters in the field face with one keystroke...even though it actually does move forward to the next face in the process. I see that the Javascript version moves the focus forward after sensing the max-len condition, NOT after sensing the attempt to enter a character that would exceed it.........hence I try to do the same here.
It seemed as though the 1st 'if all' would allow the characters entered to reach max-len....then the face length would be equal to max-len....focus would change and be ready for the 1st character to be received into the new face. ******************************************** if all [(face/max-len > 0) (length? face/text) < face/max-len] [ctx-text/edit/engage face action event]
if all [(face/max-len > 0) (length? face/text) = face/max-len] [focus-change exit]
</pre>
|
|
|
|
|
Logged
|
|
|
|
|
jfdutcher
|
Happy day !! A logic error that let 'pass' get executed one more time than it should was the cause..fixed now.
Thanks for much help rendered.
John D.
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |
News: 01-09-08 Alpha version of REBOL 3 has been released!
2285 Posts in 594 Topics by 3697 Members
Latest Member: RGDale
|