You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current methods on AppBackend for creating and updating menus are incompatible with how UIMenu works.
There are two ways to display a context menu in UIKit:
Create the UIMenu object in advance and attach it to a UIButton.
Use a UIContextMenuInteraction, which listens for a 3D Touch, long press, right-click, etc depending on the device. When it detects the appropriate form of interaction, it asks its delegate for a UIContextMenuConfiguration object, whose initializer takes a callback that returns UIMenu. It sounds convoluted, but it lets you defer creation of the UIMenu object until it's actually displayed. The problem lies in the particular form of interaction it requires.
However, UIKitBackend can't implement showPopoverMenu to accommodate this exact code. It would have to know that the button is being used for a context menu rather than an arbitrary action, and associate the menu with the button.
The text was updated successfully, but these errors were encountered:
I agree with your conclusion; AppBackend's popover API should be updated to attach pop overs to buttons rather than displaying them at specific pixel positions relative to a given widget at the point when they need to appear. If this causes issues for some of the existing backends, it may be that we have to provide two alternative APIs for backends to use when providing Menu support (backends would have to specify which one they want consumers to use, and Menu would have to have a separate implementation for each).
The current methods on
AppBackend
for creating and updating menus are incompatible with howUIMenu
works.There are two ways to display a context menu in UIKit:
UIMenu
object in advance and attach it to aUIButton
.UIContextMenuInteraction
, which listens for a 3D Touch, long press, right-click, etc depending on the device. When it detects the appropriate form of interaction, it asks its delegate for aUIContextMenuConfiguration
object, whose initializer takes a callback that returnsUIMenu
. It sounds convoluted, but it lets you defer creation of theUIMenu
object until it's actually displayed. The problem lies in the particular form of interaction it requires.The former is closer to how
Menu
actually works:swift-cross-ui/Sources/SwiftCrossUI/Views/Menu.swift
Lines 74 to 90 in 4de7709
However, UIKitBackend can't implement
showPopoverMenu
to accommodate this exact code. It would have to know that the button is being used for a context menu rather than an arbitrary action, and associate the menu with the button.The text was updated successfully, but these errors were encountered: