Changed WindowInner::show_native_popup_menu() to take parent_item (#9084)

This is necessary for popup menus to be relative to an item

This should fix the position part of #9031
This commit is contained in:
npwoods 2025-08-13 10:31:10 -04:00 committed by GitHub
parent 95171f82f2
commit e1ced68a8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 4 deletions

View file

@ -2940,7 +2940,7 @@ fn compile_builtin_function_call(
let parent_weak = _self.self_weak.get().unwrap().clone();
#init_popup
if !sp::WindowInner::from_pub(#window_adapter_tokens.window()).show_native_popup_menu(context_menu_item_tree, #position) {
if !sp::WindowInner::from_pub(#window_adapter_tokens.window()).show_native_popup_menu(context_menu_item_tree, #position, #context_menu_rc) {
#close_popup
let id = sp::WindowInner::from_pub(#window_adapter_tokens.window()).show_popup(
&sp::VRc::into_dyn(popup_instance.into()),

View file

@ -1300,8 +1300,12 @@ impl WindowInner {
&self,
context_menu_item: vtable::VRc<MenuVTable>,
position: LogicalPosition,
parent_item: &ItemRc,
) -> bool {
if let Some(x) = self.window_adapter().internal(crate::InternalToken) {
let position = parent_item
.map_to_window(parent_item.geometry().origin + position.to_euclid().to_vector());
let position = crate::lengths::logical_position_to_api(position);
x.show_native_popup_menu(context_menu_item, position)
} else {
false

View file

@ -711,9 +711,9 @@ fn call_builtin_function(
let context_menu_item = vtable::VRc::new(MenuFromItemTree::new(item_tree));
let context_menu_item = vtable::VRc::into_dyn(context_menu_item);
if component
.access_window(|window| window.show_native_popup_menu(context_menu_item, position))
{
if component.access_window(|window| {
window.show_native_popup_menu(context_menu_item, position, &item_rc)
}) {
return Value::Void;
}