代码之家  ›  专栏  ›  技术社区  ›  rnso

使用TAB在红色语言的字段之间移动

  •  1
  • rnso  · 技术社区  · 7 年前

    我有以下简单代码:

    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 )但他不在这里工作。

    1 回复  |  直到 5 年前
        1
  •  3
  •   sqlab    7 年前

    相符合的 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]
    ]