prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Request for Enhanced Mouse Event Handling in Complex Widget Layouts

Open
#1,818 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

Overview

I'm working on a project using Prompt Toolkit and facing challenges with mouse event handling for complex widget layouts. Specifically, I need to implement "on mouse over" and "on mouse out" events for widgets like Frame and Box, regardless of their nested content.

Objective

The goal is to enhance CLI interactivity by tracking mouse events across various widgets. This includes:

  • Detecting when the mouse is over a specific widget.
  • Identifying when the mouse leaves a widget.
  • Effectively working with containers that have nested elements.

Challenge

Current Prompt Toolkit capabilities seem limited in handling mouse events for nested widgets. While Window controls support mouse events, extending this to more complex containers like Frame or Box with multiple children is problematic. The key issue is tracking mouse position relative to the widget layout, essential for determining widget interaction.

Request

  1. Existing Methods: Are there undocumented features or advanced techniques in Prompt Toolkit for such mouse event handling?
  2. Feature Consideration: If not presently possible, could this feature be a valuable addition to Prompt Toolkit?
  3. Implementation Guidance: Any suggestions for implementing this, either as a contribution or a custom extension, would be greatly appreciated.

This enhancement could significantly improve Prompt Toolkit's utility for interactive CLI applications.

Thank you for your time and consideration.

Osirys and ChatGPT, that helped writing this for me because I’m a stupid human

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Prompt Toolkit's existing mouse-event handling for Window controls and compare it with the Frame and Box layouts described in the issue. Determine whether nested containers expose enough layout and pointer-position information to detect entry and exit events. Done would mean a documented, tested approach that handles widgets with nested children.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.