Skip to content

Commit

Permalink
getSelection added for textBox too (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaUndSo authored Aug 19, 2023
1 parent 097d2e1 commit 5542246
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions markdown/api/index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2293,6 +2293,8 @@

<p class="index">[object:setSelection()][api.type.TextBox.setSelection]</p>

<p class="index">[object:getSelection()][api.type.TextBox.getSelection]</p>

<p class="index">[object:setTextColor()][api.type.TextBox.setTextColor]</p>

<p class="index">[object.size][api.type.TextBox.size]</p>
Expand Down
32 changes: 32 additions & 0 deletions markdown/api/type/TextBox/getSelection.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# object:getSelection()

> --------------------- ------------------------------------------------------------------------------------------
> __Type__ [Function][api.type.Function]
> __Object__ [TextBox][api.type.TextBox]
> __Library__ [native.*][api.library.native]
> __Return value__ none
> __Revision__ [REVISION_LABEL](REVISION_URL)
> __Keywords__ getSelection
> __See also__ [native.newTextBox()][api.library.native.newTextBox]
> --------------------- ------------------------------------------------------------------------------------------

## Overview

Returns the cursors first and last position.

## Syntax

object:getSelection()

## Example

``````lua
local textBox = native.newTextBox( 160, 240, 280, 40 )

textBox.text = "asdf"
native.setKeyboardFocus( textBox )

local start, finish = textBox:getSelection()
-- if native cursor is placed after the "f" in the text, start and finish would return 4, 4
-- if native cursor is selecting the whole text, start and finish would return, 0, 4

0 comments on commit 5542246

Please sign in to comment.