【问题标题】:How to add line break within text field on LiveCode?如何在 LiveCode 的文本字段中添加换行符?
【发布时间】:2016-04-27 23:34:52
【问题描述】:

在 LiveCode 上的文本字段中,我想要两行单独的文本。应该是这样的:

句子的第一行
第二行句子

我该怎么做?

【问题讨论】:

    标签: livecode


    【解决方案1】:

    如果您手动输入文本,请键入回车键或回车键以将回车字符添加到文本字段。您也可以通过脚本来执行此操作。

    使用cr 在文本字段中定义返回值。例如。如果您有一个包含一个字段的堆栈,请执行以下行将两行放入文本字​​段:

    put "First line of sentence" & cr & "Second line of sentence" into field 1
    

    例如,您可以将这一行包含在按钮的 mouseUp 处理程序中。

    【讨论】:

    • 马克的回答很到位。请记住,LiveCode 中的行尾字符是 ASCII 10。RETURN、CR 和 LINEFEED 都是代表 ASCII 10 的同义词。
    【解决方案2】:

    您可以更进一步,更加熟悉 LC 所说的“块表达式”。假设您在某个字段中有一个句子。在按钮的脚本中考虑这一点:

    on mouseUp
      put return after word 3 of fld "yourField"
    end mouseUp
    

    现在试试这个:

    on mouseUp
      put return & return after word 3 of fld "yourField"
    end mouseUp
    

    【讨论】:

      【解决方案3】:

      我想知道同样的事情,然后不断修补并发现“食谱”几乎可以肯定有更好的方法,但从逻辑上讲,这是我能想到的最好的方法。仍在学习文档,找不到待办事项列表示例。

      on mouseUp
         put the text of field"NewItem" into NewItem
         put the text of field"GroceryList" into GroceryList
         set the text of field"GroceryList" to empty
         put GroceryList & return & NewItem into GroceryList
         set the text of field "GroceryList" to GroceryList
         set the text of field"NewItem" to empty
      end mouseUp
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-04-19
        • 1970-01-01
        • 2022-07-28
        • 2010-10-26
        • 2014-12-01
        相关资源
        最近更新 更多