logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Annoying menu bug (Unreal Gold) (Read 1713 times)
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Annoying menu bug (Unreal Gold)
May 10th, 2015 at 9:34am
Print Post  
Whenever I use Alt+Tab in order to switch to other application and then switch back to Unreal while the main game menu is open, an attempt to write something in the game console leads to triggering hot-keys of the main menu. This issue can be avoided by pressing Alt before typing, but sometimes I forget to press it, and then I get weird results like sudden exit from the game, activation of TimeDemo statistics, opening developer's web-site, and so on.

My OS: Windows 8.1
Game versions I've tried: 226b and 227i/j Gold
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Annoying menu bug (Unreal Gold)
Reply #1 - Jan 31st, 2016 at 12:22pm
Print Post  
Pressing Alt results in execution of Console.KeyEvent with Key == 0x12 && Action == IST_Press. Releasing Alt results in execution of Console.KeyEvent with Key == 0x12 && Action == IST_Release.

Depending on the value of Action, KeyEvent calls UWindowMenuBar.HotKeyDown or UWindowMenuBar.HotKeyUp:

Code
Select All
function bool HotKeyDown(int Key, float X, float Y)
{
	local UWindowMenuBarItem I;

	if (Key == 0x12)
		bAltDown = True;

	if (bAltDown)
	{
		// Check for hotkeys in each menu item
		for ( I = UWindowMenuBarItem(Items.Next); I != None; I = UWindowMenuBarItem(I.Next) )
		{
			if (Key == I.HotKey)
			{
				if (Selected != None)
					Selected.DeSelect();
				Selected = I;
				Selected.Select();
				Select(Selected);
				bAltDown = False;
				return True;
			}
		}
	}
	return False;
}

function bool HotKeyUp(int Key, float X, float Y)
{
	if (Key == 0x12)
		bAltDown = False;

	return False;
} 


So, pressing Alt makes UWindowMenuBar.bAltDown equal to true, releasing Alt makes UWindowMenuBar.bAltDown equal to false. If Tab is pressed while Alt is being held, the application becomes inactive and does not register releasing Alt anymore, so we don't get a call to Console.KeyEvent with Key == 0x12 && Action == IST_Release and we don't get a call to HotKeyUp with Key == 0x12.

After returning to the game, the equality UWindowMenuBar.bAltDown == true still holds, so the menu behaves as if Alt would be pressed.

I see two possible resolutions:

1) We could try to handle WM_KILLFOCUS for the window whose messages are translated into UScript events, namely simulate releasing Alt key if the window received WM_SYSKEYDOWN with key VK_MENU and there was no further WM_SYSKEYUP with key VK_MENU:

Code (C++)
Select All
// called from WindowProc
void ProcessAltKey(
    HWND   hwnd,
    UINT   uMsg,
    WPARAM wParam,
    LPARAM lParam)
{
    static bool bAltDown;
    static LPARAM lParamAltDown;

    if (uMsg == WM_SYSKEYDOWN && wParam == VK_MENU)
    {
        bAltDown = true;
        lParamAltDown = lParam;
    }
    else if (uMsg == WM_SYSKEYUP && wParam == VK_MENU)
        bAltDown = false;
    else if (uMsg == WM_KILLFOCUS && bAltDown)
        WindowProc(hwnd, WM_SYSKEYUP, VK_MENU, lParamAltDown | 0xC0000000);
} 


2) It's possible to implement a native function (if such does not exist yet) that could tell if Alt is actually pressed (implementation for Windows could use GetKeyState) and modify scripts accordingly.
  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7925
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Annoying menu bug (Unreal Gold)
Reply #2 - Mar 6th, 2016 at 9:40am
Print Post  
from what I see, this should be handled by ResetInput, which is called by WM_KILLFOCUS anyway. It seems they just forgot to do KeyEvent as well.
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo