bevyengine / bevyengine/bevy

TextSpan can not recieve Pointer<Click> events

Open
#15,984 2 comments 0 reactions 0 assignees View on GitHub
A-Picking A-UI C-Feature D-Modest S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?

Text can accept Pointer events, but TextSpan cannot. I wanted to make a link inside the large text and I can't implement this with multiple Texts because the layout of the text will be bad.

## What solution would you like?

Add support to recieve Pointer events for TextSpan

## What alternative(s) have you considered?

Provide some other check that the mouse is over a particular TextSpan

## Additional context

```rust
use bevy::prelude::*;

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_observer(span_observer)
.add_systems(Startup, setup)
.run();

}

fn setup(
mut commands: Commands,
) {
commands.spawn(Camera2d::default());
commands.spawn(
Text::new("")
).with_child(TextSpan::from("text_span"));
}

fn span_observer(
trigger: Trigger>,
q_spans: Query<(Entity, &TextSpan)>,
q_text: Query<(Entity, &Text)>,
) {
if let Ok((e, _)) = q_spans.get(trigger.entity()) {
info!("span_observer {}", e); //never called event if click directly on text span
}

if let Ok((e, _)) = q_text.get(trigger.entity()) {
info!("text_observer {}", e);
}
}
```

```bash
2024-10-18T11:32:03.020663Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 10 Pro", kernel: "19045", cpu: "AMD Ryzen 7 2700X Eight-Core Processor", core_count:
"8", memory: "63.9 GiB" }
2024-10-18T11:32:03.578891Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA TITAN Xp", vendor: 4318, device: 6914, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "560.94", backend: Vulkan }
2024-10-18T11:32:04.556414Z INFO bevy_winit::system: Creating new window "App" (0v1#4294967296)
2024-10-18T11:32:08.781002Z INFO bug: text_observer 8v1
```

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Start by tracing the TextSpan and Text handling for Pointer from the provided reproduction, comparing how each observer target is resolved. Done means clicking a span triggers the observer for that span, with coverage for the shown case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.