Skip to content
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

Document MenuBar and ContextMenu #7502

Merged
merged 3 commits into from
Jan 31, 2025
Merged

Document MenuBar and ContextMenu #7502

merged 3 commits into from
Jan 31, 2025

Conversation

ogoffart
Copy link
Member

@ogoffart ogoffart commented Jan 30, 2025

And don't mark them as experimental.

Which also enable the muda dependency by default on mac and windows


### show(Point)

Call this function to programmatically show the context menu at the given position relative to the `ContextMenu` element.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the feeling that we might revisit these semantics in the API review ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, feel free to let me know what feels wrong there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guts feeling is that we may be better off accepting absolute coordinates, to disambiguate the API.

The relative coordinates make sense when ContextMenu surrounds the area that provides the context menu, but I'm not sure one would call show() then and instead rely on the automatic support for the right click?

And when it's not surrounding, the relative coordinates require additional steps:

ctx := ContextMenu { MenuItem { ... } MenuItem { ... } }

canvas := SomeCanvasOfThings {
    something-selected-via-right-click(pos) => {
        ctx.show({x: pos.x - canvas.x + ctx.x, y: pos.y - canvas.y + ctx.y}); // Is this correct?
    }
}

As opposed to just taking absolute coordinates:

ctx := ContextMenu { MenuItem { ... } MenuItem { ... } }

canvas := SomeCanvasOfThings {
    something-selected-via-right-click(pos) => {
        ctx.show({x: pos.x + canvas.absolute-position.x, y: pos.y + canvas.absolute-position.y});
    }
}

docs/astro/src/content/docs/reference/window/window.mdx Outdated Show resolved Hide resolved
docs/astro/src/content/docs/reference/window/window.mdx Outdated Show resolved Hide resolved
docs/astro/src/content/docs/reference/window/window.mdx Outdated Show resolved Hide resolved
Apply suggestions from code review

Co-authored-by: Simon Hausmann <[email protected]>
@ogoffart ogoffart merged commit b68f7bd into master Jan 31, 2025
37 checks passed
@ogoffart ogoffart deleted the olivier/menu branch January 31, 2025 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants