- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 23.5k
 
[PopupMenu] Fix submenu item not popping on mouse enter #110256
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
base: master
Are you sure you want to change the base?
Conversation
| 
           This   | 
    
88a0428    to
    a251137      
    Compare
  
    | 
           Doesn't seem to fix the issue godot.windows.editor.dev.x86_64_Kdv2xEbSfA.mp4 | 
    
| 
           It can be fixed by storing the next submenu that should show and once the timer timeouts we show it here after we hide the previous submenu. void PopupMenu::_minimum_lifetime_timeout() {
	close_allowed = true;
	// If the mouse still isn't in this popup after timer expires, close.
	if (!activated_by_keyboard && !get_visible_rect().has_point(get_mouse_position())) {
		_close_pressed();
	}
}Or by having smaller wait time for both timers, I have tried  	submenu_timer = memnew(Timer);
	submenu_timer->set_wait_time(0.3);
	submenu_timer->set_one_shot(true);
	submenu_timer->connect("timeout", callable_mp(this, &PopupMenu::_submenu_timeout));
	add_child(submenu_timer, false, INTERNAL_MODE_FRONT);
	minimum_lifetime_timer = memnew(Timer);
	minimum_lifetime_timer->set_wait_time(0.3);
	minimum_lifetime_timer->set_one_shot(true);
	minimum_lifetime_timer->connect("timeout", callable_mp(this, &PopupMenu::_minimum_lifetime_timeout));
	add_child(minimum_lifetime_timer, false, INTERNAL_MODE_FRONT);
Edit:   | 
    
| 
           Also this may be related to why the popup menu didn't receive the motion event when the mouse entered.  | 
    
          
 The whack-a-mole continues - thanks for finding that. If you set the submenu timer to 0.1 does it still act the same per @WhalesState? Is there a movement sequence you can replicate this on an Editor menu? I will set this up for myself and go back on the hunt. 
 I agree that 0.1 feels better - any reason we can't set the default to 0.1 instead of 0.3?  | 
    
          
 I just tested with the MRP from the issue you linked 🙃 
 Yes.  | 
    
          
 That's pretty funny! My notoriety must be in reinventing the wheel. I've been testing with a much fancier menu that doesn't exhibit the issues as obviously for an as yet unknown reason.  | 
    
          
 Okay, go to project settings and disable  
 There seems to be an issue regarding incorrect determination of the mouse leaving the safe area.  | 
    
          
 Yes, The issue is that the parent window only process one event while another window has focus, but when you disable embedding sub-windows they become just fake windows extending   | 
    
          
 Also this issue is in both embedded and non-embedded windows so maybe you forgot to revert back the timer changes while testing or you test with the changes from this PR, i have tested with editor submenus in master and the issue also exists there by default and the editor is not embedding subwindows. Screencast.From.2025-09-20.23-54-36.mp4 | 
    
| 
           Also check what happens here, the root window receives one mouse event when another window is focused but when you focus it no other window receives any input, the settings window is exclusive so the parent window shouldn't receive any input at all. Screencast.From.2025-09-20.23-45-59.mp4 | 
    
          
 The PR fixed the issue with non-embedded windows and the Editor, though I found a couple of bugs there that I'm taking care of. What I've got working now for embedded widows is to emit the  What you demonstrated regarded no window receiving input, might certainly be related to the closed submenu blocking input to the parent menu, which is the source of the blocked submenu issue. This is a deeper problem with   | 
    
a251137    to
    b51c6d2      
    Compare
  
    b51c6d2    to
    49b8f45      
    Compare
  
    | 
           After a lot of frustration, I finally had to get rid of the  The other major problem was the fixes for issues with embedded vs. non-embedded subwindows were completely different. The only way to get embedded subwindows to work was connecting  When the mouse moves out of a submenu item, it's last relative motion state inside its menu item is preserved, and if it's moving into the lower right quadrant (or lower left if right-to-left layout), it will start the  Finally, I reduced the default submenu delay time from   | 
    
49b8f45    to
    fd98bf6      
    Compare
  
    | 
           This push adds support for right-to-left layouts for the direction testing of mouse movements toward an open submenu.  | 
    
fd98bf6    to
    39e2f25      
    Compare
  
    39e2f25    to
    c8aae8e      
    Compare
  
    | 
           This push handles submenu positions where the right-to-left layout setting is overwritten because of inadequate screen space for the submenu, so the submenu position is left vs. right or the converse.  | 
    
| 
           I tried visualizing the dot products and different menus. Submenus can be above the cursor when tall near the bottom, and the calculated range doesn't match:  
Moving toward the top of this submenu closes it. I found references of how this is done elsewhere https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown , https://codepen.io/popov654/pen/XyGXzb  | 
    
          
 I like this idea! I had not considered that case of the menu originating near the bottom of the screen. I had assumed the submenu would always project below the menu item. Shouldn't be too much work to calculate those vectors aiming at the corners. Nice also to see the quadrant orientation - thanks. This also future-proofs having submenus that pop with the selected submenu choice aligned with the parent menu item. It's something we don't do now, but would be nice to implement someday.  | 
    
a6617fb    to
    71228b8      
    Compare
  
    | 
           This push improves the mouse movement direction detection so the detection angles are based on the position and height of the submenu. I included debug draw lines to visualize the detection angles from the mouse position, which you can see in the screen recordings below. The detection now works correctly for both left and right side submenus, and submenus shifted by any amount vertically. Screen.Recording.2025-10-25.at.1.42.55.PM.movScreen.Recording.2025-10-25.at.1.39.15.PM.mov | 
    
| 
           The PR makes submenus close instantly if the cursor leaves the item.  | 
    
          
 The intended behavior is that the submenu stays open for 0.5 seconds if you are moving the mouse toward the submenu upon exiting the parent menu item. Otherwise, the submenu should close instantly when exiting the parent item, because you are moving downward or otherwise away from the submenu. Are you observing something else like a bug? Do you see some other behavior other than what's shown in the last screen recordings above?  | 
    
          
 The actual feeling is that the submenu closes faster than the current   | 
    
eead1dc    to
    770c23e      
    Compare
  
    770c23e    to
    6107c5c      
    Compare
  
    
          
  | 
    
          
 Thanks for comments. I'm working on a fix for this - the parent item also can blink when the mouse moves across another item on the way to the submenu. 
 I can't reproduce this - what platform is it happening on? Is this on an Editor menu?  | 
    
| 
           Will do. By-the-way, the new default popup total delay is   | 
    
          
 Do you get any log output on crash? This might be OS-dependent. I'll see if I can reproduce it on Windows.  | 
    
           | 
    
| 
           Excellent - this means it's not a platform issue, and I know where to look...  | 
    
| 
           I've fixed the crashing and other issues, and added several error checks to prevent any similar crashes. The crash culprit was the submenu timer was running as another submenu was closed. I'm trying to wrap things up regarding the parent item highlight flickering, and ran into this bug - #112358. I can work around it, but it would be nice to sort out.  | 
    


Fixes #77246, Fixes #102081 and Fixes #70361.
This PR fixes the issue where a submenu would not open on hover until the mouse was jiggled. It also adds an additional delay to close a submenu when the mouse is moving to the right and goes across another submenu item. This provides time to reach a long submenu without it being closed by touching another submenu item.
[Edit: The issue below went away after the push eliminating
minimum_lifetime_timer. See comments below regarding probable source of the issue.]There were several things confounding the issue, one of which is mysterious. In_activate_submenu()callingsubmenu_pum->popup()would intermittently fail, leaving the submenu invisible, even whensubmenu_pum->is_visible()shows as true. This is fixed by aprocess_frame, so I added a hack to do this, but I'm sure there is a better way. There should be a fix maybe inWindowthat would detect the incomplete rendering?Here's the line that can be improved: