LIVE PORTAL Telegram v11.8 API Synchronized Free Animated Stickers
shield_person ADMIN LOGGED IN + Write Guide
admin_panel_settings ADMIN CONTROLS Guide #219 • Tips & Video Shorts
Telegram Partial Text Selection Architecture: Sub-String Character Ranges, Contextual Action Bars & Formatted Clipboard Export
select_all Sub-String Ranges & Contextual Clipboard Dispatch

Telegram Partial Text Selection Architecture: Sub-String Character Ranges, Contextual Action Bars & Formatted Clipboard Export

In most messaging applications, copying text is an all-or-nothing ordeal. Tapping a message copies thousands of characters, forcing users to paste massive walls of text into external notes apps just to crop out a single tracking number, code snippet, or address. Telegram eliminated this friction through granular partial text selection. By implementing custom touch gesture listeners that capture sub-string character offsets, dynamic bounding handles, and a floating contextual action bar, users can select, copy, share, or quote-reply to exact excerpts with surgical precision.

verified Official Telegram Technical Showcase: Press and hold a message, drag your finger across the specific text range, and select Copy, Share, or Quote.
highlight

1. Sub-String Character Boundary Offsets & Hit Testing

In conventional mobile UI toolkits, message chat bubbles are wrapped inside generic list view items that treat touch gestures as row-level clicks. When a user holds down a bubble, standard apps trigger a row selection mode. Telegram overrides this by delegating touch events directly to custom TextLayoutView renderers:

Hit-Testing & Coordinate Calculation:

Touch Event (x, y) -> getOffsetForHorizontal(line, x) -> Bounds [start_index, end_index] -> Draw Bounding Selection Highlight Rectangles -> Position Left & Right Drag Pin Handles.

Users can drag the left and right selection handles with micro-fine accuracy. The touch listener features magnetic snapping to whitespace and punctuation boundaries, ensuring whole words can be highlighted without frustrating letter-by-letter jitter.

format_quote

2. Contextual Action Bar & Quote-Reply Integration

Once a sub-string range is highlighted, Telegram immediately floats a contextual pill bar directly above the selection, offering four primary actions:

content_copy Granular Clipboard Copy

Copies solely the highlighted text characters into the system clipboard, stripping away surrounding conversational chatter, timestamps, and author headers.

format_quote Direct Quote-Reply

Mounts the selected excerpt directly into the compose bar as an indented blockquote reply, letting you respond specifically to one sentence within a long essay.

share Direct App Forwarding

Launches the system share sheet or internal chat picker to dispatch the exact snippet to another contact or channel without copying to clipboard first.

code_blocks

3. Formatted Clipboard & Entity Serialization

Telegram messages frequently contain rich formatting entities: bold, italics, strikethrough, inline monospace code, and embedded hyperlinks. When a partial selection intersects formatted spans, the clipboard serializer calculates entity boundaries:

memory MIME-Type Multi-Format Export

The selection engine writes both text/plain and text/html payloads into the operating system clipboard. If you paste into an IDE or code editor, you get pure sanitized plain text. If you paste into Telegram, Word, or Google Docs, the bold weights, code fonts, and hyperlinks remain beautifully preserved.

touch_app

4. Interactive Partial Selection & Quote Studio

Test Telegram's partial text selection mechanism. Highlight text in the sample message below or click one of the quick preset ranges. Inspect the live character offset calculation, clipboard export, and quote-reply preview!

select_all Sub-String Selection & Action Bar Simulator
Offsets: None
Durov Official 14:32

Telegram is designed for freedom and privacy. You can select any portion of a message to copy or share, instead of copying the full text. Our MTProto architecture ensures zero data leaks and sub-second global cloud sync.

Quick Highlight Presets:
[INIT] Text selection listener ready. Highlight text above or click a preset.
account_tree One-Page Executive Infographic

Telegram Partial Text Selection Architecture at a Glance

A comprehensive visual flowchart summarizing character boundary hit testing, floating contextual action bars, and formatted quote-reply exports.

Telegram Partial Text Selection Architecture Infographic Flowchart
💡 Tip: Click the image to view the ultra-sharp full-resolution infographic poster in full lightbox viewer.
admin_panel_settings ADMIN Guide #219 Actions
Enlarged Preview
Click anywhere outside or press ESC to close viewer
smart_display Telegram Video Short
1080p HD
Official Source: @TelegramTips Post #44 Press ESC or click outside to close