18 lines
5.3 KiB
JavaScript
18 lines
5.3 KiB
JavaScript
import{_ as s,o as e,c as a,Q as t}from"./chunks/framework.4313453f.js";const x=JSON.parse('{"title":"Textfield","description":"","frontmatter":{"outline":"deep"},"headers":[],"relativePath":"references/textfield.md","filePath":"references/textfield.md","lastUpdated":null}'),n={name:"references/textfield.md"},l=t(`<h1 id="textfield" tabindex="-1">Textfield <a class="header-anchor" href="#textfield" aria-label="Permalink to "Textfield""></a></h1><p>Textfields are objects that allow users to write text in multiple lines, similar to the default edit script.</p><h2 id="properties" tabindex="-1">Properties <a class="header-anchor" href="#properties" aria-label="Permalink to "Properties""></a></h2><table><thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>lines</td><td>table</td><td>A collection of strings, where each string represents a separate line in the Textfield.</td></tr><tr><td>lineIndex</td><td>number</td><td>The current line number where the cursor is positioned.</td></tr><tr><td>scrollIndexX</td><td>number</td><td>The horizontal scroll position, determining which part of the text is visible when the text width exceeds the Textfield width.</td></tr><tr><td>scrollIndexY</td><td>number</td><td>The vertical scroll position, deciding which part of the text is visible when the number of lines exceeds the Textfield's height.</td></tr><tr><td>cursorIndex</td><td>number</td><td>The current position of the cursor within the line determined by lineIndex.</td></tr></tbody></table><h2 id="example" tabindex="-1">Example <a class="header-anchor" href="#example" aria-label="Permalink to "Example""></a></h2><p>Here’s a simple example showcasing how to instantiate a Textfield object within the Basalt framework:</p><div class="language-lua vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">lua</span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#F97583;">local</span><span style="color:#E1E4E8;"> main </span><span style="color:#F97583;">=</span><span style="color:#E1E4E8;"> basalt.</span><span style="color:#79B8FF;">createFrame</span><span style="color:#E1E4E8;">()</span></span>
|
||
<span class="line"><span style="color:#F97583;">local</span><span style="color:#E1E4E8;"> aTextfield </span><span style="color:#F97583;">=</span><span style="color:#E1E4E8;"> </span><span style="color:#B392F0;">main</span><span style="color:#E1E4E8;">:</span><span style="color:#79B8FF;">addTextfield</span><span style="color:#E1E4E8;">()</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="color:#6A737D;">-- User writes text into the Textfield</span></span>
|
||
<span class="line"><span style="color:#6A737D;">-- ...</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="color:#6A737D;">-- Retrieve the text from the Textfield</span></span>
|
||
<span class="line"><span style="color:#F97583;">local</span><span style="color:#E1E4E8;"> allText </span><span style="color:#F97583;">=</span><span style="color:#E1E4E8;"> </span><span style="color:#79B8FF;">table.concat</span><span style="color:#E1E4E8;">(aTextfield.</span><span style="color:#B392F0;">lines</span><span style="color:#E1E4E8;">, </span><span style="color:#9ECBFF;">"</span><span style="color:#79B8FF;">\\n</span><span style="color:#9ECBFF;">"</span><span style="color:#E1E4E8;">)</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;">basalt.</span><span style="color:#79B8FF;">debug</span><span style="color:#E1E4E8;">(allText)</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#D73A49;">local</span><span style="color:#24292E;"> main </span><span style="color:#D73A49;">=</span><span style="color:#24292E;"> basalt.</span><span style="color:#005CC5;">createFrame</span><span style="color:#24292E;">()</span></span>
|
||
<span class="line"><span style="color:#D73A49;">local</span><span style="color:#24292E;"> aTextfield </span><span style="color:#D73A49;">=</span><span style="color:#24292E;"> </span><span style="color:#6F42C1;">main</span><span style="color:#24292E;">:</span><span style="color:#005CC5;">addTextfield</span><span style="color:#24292E;">()</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="color:#6A737D;">-- User writes text into the Textfield</span></span>
|
||
<span class="line"><span style="color:#6A737D;">-- ...</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="color:#6A737D;">-- Retrieve the text from the Textfield</span></span>
|
||
<span class="line"><span style="color:#D73A49;">local</span><span style="color:#24292E;"> allText </span><span style="color:#D73A49;">=</span><span style="color:#24292E;"> </span><span style="color:#005CC5;">table.concat</span><span style="color:#24292E;">(aTextfield.</span><span style="color:#6F42C1;">lines</span><span style="color:#24292E;">, </span><span style="color:#032F62;">"</span><span style="color:#005CC5;">\\n</span><span style="color:#032F62;">"</span><span style="color:#24292E;">)</span></span>
|
||
<span class="line"><span style="color:#24292E;">basalt.</span><span style="color:#005CC5;">debug</span><span style="color:#24292E;">(allText)</span></span></code></pre></div>`,7),o=[l];function p(r,c,i,d,h,y){return e(),a("div",null,o)}const f=s(n,[["render",p]]);export{x as __pageData,f as default};
|