-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bounding box for label does not set focus #17701
Comments
Yes, it needs a transparent background for hittest to work. That's by design. Updating the style however may be a good idea 🤔 |
Ah, makes sense. It was surprising though, having a block element with no initial hitbox when its entire purpose is making it easier to select another element with a smaller hitbox. Will close this issue anyways, as this is intended behavior then. |
I meant it's intended that it needs a Background. So we may want to add it by default, might be an oversight when it was first created. Feel free to provide a PR. |
@timunie Is this as simple as setting the background as transparent in the label constructor so that all label have a transparent background rather than none/null? /// <summary>
/// Initializes instance of <see cref="Label"/> control
/// </summary>
public Label()
{
+ Background = Brushes.Transparent;
} |
In the constructor would be a bad idea. Add it here as setter: Need also to be updated for simple theme if you want to file a PR |
Why would it be better to add the default behaviour to a theme rather than the base properties of the control itself? |
In that case their theme should have it. |
Perhaps that's the case but that doesn't help me understand why? |
Okay let me try to explain it a bit more. Setting it as you did will cause it to be a local set property which then can't be changed except for other local set values. So that will break all styles that have set it before. If anything we could consider is to override default metadata. Not sure if that's a breaking change or not. See: https://docs.avaloniaui.net/docs/guides/custom-controls/how-to-create-advanced-custom-controls |
Describe the bug
When adding a label and another element to a document tree, the label's bounding box does not trigger focus onto the other element unless its background property has been set. The label's inner text does trigger the focus change regardless.
To Reproduce
Shove this into a Window and click anywhere in the bounding box of either label, but not on the text itself. Setting the background to
Transparent
works, but leaving it out does not.Violet is for illustrative purposes - it visualizes the bounding box size
Expected behavior
Focus shifting when clicking anywhere in the bounding box
Avalonia version
Avalonia 11.2.1
OS
Windows
Additional context
I have not tested other OSes, but I assume it might be affected there as well.
Perhaps changing
Background
onLabel
to default toTransparent
would be a good fix here?The text was updated successfully, but these errors were encountered: