2017-10-25 5 views
0

나는 간단한 코드 다음 한 :레드 언어 필드 사이를 이동 탭을 사용하여

Red [] 
view [ 
    text "Value of x:" f1: field "" return 
    text "Value of y:" f2: field "" return 
    text "Read Sum:" tt: text "" return 
    button "Calculate" [ 
     tt/text: to-string ((to-integer f1/text) + (to-integer f2/text)) ] 
    button "Quit" [quit] ] 

하나가 TAB 키를 사용하여 서로 다른 필드 사이를 이동 할 수 있도록 어떻게 코드를 추가 할 수 있습니까? 분명히 Rebol (http://www.rebol.com/how-to/fields.html)에서 작동하지만 여기서는 작동하지 않습니다. `버튼을 "계산"[TT/데이터 : F1/데이터 당신이 코드를 단순화 할 수 있도록

답변

2

따라 gitter archive

handle-key: function [e prev-fld next-fld][ 
    k: e/key 
    if k = tab [ 
     either e/shift? [win/selected: prev-fld][win/selected: next-fld] 
    ] 
] 
view [ 
    text "Value of x:" f1: field "" on-key [handle-key event tt f2] return 
    text "Value of y:" f2: field "" on-key [handle-key event f1 tt] return 
    text "Read Sum:" tt: text "" on-key [handle-key event f2 f1] return 
    button "Calculate" [ 
     tt/text: to-string ((to-integer f1/text) + (to-integer f2/text))  
    ] 
    button "Quit" [quit] 
    do [win: self win/selected: f1] 
] 
+0

보기는 이제 텍스트 '와'당신을 위해 field' 내용'에 대한 변환을 처리 할 수 ​​있습니다 + f2/데이터]'. – DocKimbel