Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

Make Inline / TextElement inherit from InputElement to enable pointer/keyboard input handling

Open wieslawsoltes opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe.

In order to implement Hyperlink inline pointer / keyboard input is required.

Describe the solution you'd like

Make Inline / TextElement inherit from InputElement to enable pointer/keyboard input handling

Describe alternatives you've considered

Embedding TextBlock's controls?

Additional context

https://github.com/AvaloniaUI/Avalonia/blob/d39b927266e18670f230b0fd16d58074f65dc512/src/Avalonia.Controls/Documents/Inline.cs#L11

https://github.com/AvaloniaUI/Avalonia/blob/d39b927266e18670f230b0fd16d58074f65dc512/src/Avalonia.Controls/Documents/TextElement.cs#L9

https://github.com/AvaloniaUI/Avalonia/blob/d39b927266e18670f230b0fd16d58074f65dc512/src/Avalonia.Base/Input/InputElement.cs#L21

wieslawsoltes avatar Feb 03 '23 09:02 wieslawsoltes

The concrete implementation InputElement should not be required to handle input in some inline. Inline itself is not a Visual so this will not be possible. Instead only IInputElement should be required.

Gillibald avatar Feb 03 '23 12:02 Gillibald

So how did you end up implementing this on your side?

Gillibald avatar Apr 13 '23 10:04 Gillibald

So how did you end up implementing this on your side?

https://github.com/wieslawsoltes/HackerNews/blob/7f4593ac1b2ec92a3ad935c5a959c59c11a479ff/HackerNews/Controls/Hyperlink.cs#L14

wieslawsoltes avatar Apr 13 '23 10:04 wieslawsoltes

I don't think this issue is solved. You are adding a styled button to the text layout. This issue is about making TextRun's hit testable for commands etc.

Gillibald avatar Apr 13 '23 13:04 Gillibald