Skip to main content

FletTextfieldExtras control for Flet

Project description

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

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.1.tar.gz (3.0 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.1-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flet_textfield_extras-0.1.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for flet_textfield_extras-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e47e82ed698015cfad65573ef8e1b69fbca88c67885efb5439d5718f24b8226e
MD5 9286ee95f744b49f8959e58bbacf337e
BLAKE2b-256 edfe5f985a04c9bd4032b6a9b86619cd46bfeba2ede13c9358493846dc0e0a40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flet_textfield_extras-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f14fe0d40fbe57d066c4c2fa16c52f49fbb0a8f954ca44f7afd6fd060a5f17e
MD5 10168455d05b8dea11c74fb4dc7cd2fe
BLAKE2b-256 cf9b87d7e8fc1403619d242b359c651c5d1a68eb5a4b27ccf5e73125f0c360db

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