Skip to main content

FletTextfieldExtras control for Flet

Project description

FletTextfieldExtras

The FletTextfieldExtras control is an enhanced version of the standard Flet TextField, offering a wider range of text manipulation and selection capabilities. It provides additional properties and methods for handling text selection, cursor position, and text insertion, giving developers more granular control over user input. This makes it ideal for building applications that require rich text editing features or precise cursor and selection management.

Installation

The python api can be installed from PyPI:

pip install flet-textfield-extras

Add dependency to pyproject.toml of your Flet app:

  • Git dependency

Link to git repository:

dependencies = [
  "flet-textfield-extras @ git+https://github.com/Progressing-Llama/Flet-Textfield-Extras",
  "flet>=0.28.3",
]
  • PyPi dependency If the package is published on pypi.org:
dependencies = [
  "flet-textfield-extras",
  "flet>=0.28.3",
]

Build your app:

flet build macos -v

Documentation

Link to documentation

Text Selection Properties and Functions

The FletTextfieldExtras control extends the standard Flet TextField to provide enhanced text selection capabilities. It introduces new properties and methods for getting and setting the text selection, as well as handling selection-related events.

Property/Function Type Description
text_selection TextSelection Represents the current text selection state of the TextField as a TextSelection object.
on_selection_change Callable[[TextSelection], None] An event handler that is called when the text selection within the TextField changes. It passes the new TextSelection object to the handler.
set_cursor_position(position: int, update: bool = True) function Sets the cursor position (a collapsed selection) at the specified position. If update is True, the UI is updated immediately.
get_cursor_position() function Returns the current cursor position.
insert_text(text: str, position: int) function Inserts the given text at the specified position in the TextField's value.
get_selection() function Returns the currently selected text as a string.
set_selection(base_offset: int, extent_offset: int) function Sets the text selection from base_offset to extent_offset.

TextSelection Object

The TextSelection class is a crucial part of the enhanced selection functionality. It represents the state of the text selection and is used by the text_selection property and the on_selection_change event.

Property Type Description
baseOffset int The starting offset of the selection.
extentOffset int The ending offset of the selection.
isCollapsed bool True if the selection is a collapsed cursor, meaning baseOffset and extentOffset are the same.
isValid bool True if the selection is valid.
start int The index of the first character in the selection. This is the minimum of baseOffset and extentOffset.
end int The index after the last character in the selection. This is the maximum of baseOffset and extentOffset.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flet_textfield_extras-0.1.2.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flet_textfield_extras-0.1.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file flet_textfield_extras-0.1.2.tar.gz.

File metadata

  • Download URL: flet_textfield_extras-0.1.2.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flet_textfield_extras-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c4a44f608f3fd42371057271dcddedde4e253381493c178c50be727acf27af68
MD5 5c1dee8ac1bea09cd00c3df9f20586c9
BLAKE2b-256 1d8fa553385237120ae5b2827cc318a10ed628431a12dd6371ed0639b3f5d41a

See more details on using hashes here.

File details

Details for the file flet_textfield_extras-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for flet_textfield_extras-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a3893d5063cf16f26ca21cf03af97c90560961f5102e2e4a5cfb948eb3a68c43
MD5 ba99a4ee4fb529e7536e2e94bf6e495a
BLAKE2b-256 bdc20a9c821aa30c46af09dbfdb1a2083e2df8ffdf3eda9da0517c0bcadf6de3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page