mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-23 09:19:32 +00:00
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:
parent
95171f82f2
commit
e1ced68a8d
3 changed files with 8 additions and 4 deletions
|
|
@ -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()),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue