🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

flet-textfield-extras

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flet-textfield-extras

FletTextfieldExtras control for Flet

pipPyPI
Version
0.1.2
Maintainers
1

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/FunctionTypeDescription
text_selectionTextSelectionRepresents the current text selection state of the TextField as a TextSelection object.
on_selection_changeCallable[[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)functionSets the cursor position (a collapsed selection) at the specified position. If update is True, the UI is updated immediately.
get_cursor_position()functionReturns the current cursor position.
insert_text(text: str, position: int)functionInserts the given text at the specified position in the TextField's value.
get_selection()functionReturns the currently selected text as a string.
set_selection(base_offset: int, extent_offset: int)functionSets 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.

PropertyTypeDescription
baseOffsetintThe starting offset of the selection.
extentOffsetintThe ending offset of the selection.
isCollapsedboolTrue if the selection is a collapsed cursor, meaning baseOffset and extentOffset are the same.
isValidboolTrue if the selection is valid.
startintThe index of the first character in the selection. This is the minimum of baseOffset and extentOffset.
endintThe index after the last character in the selection. This is the maximum of baseOffset and extentOffset.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts