Browse Source

Fixing menu bar shortcuts & shortcuts in general

Marko Pintera 10 years ago
parent
commit
57c37f1601

+ 3 - 2
BansheeCore/Source/Win32/BsWin32Platform.cpp

@@ -303,8 +303,9 @@ namespace BansheeEngine
 		UINT virtualKey = MapVirtualKeyExW(keyCode, 1, keyboardLayout);
 
 		wchar_t output[2];
-		if (ToUnicodeEx(virtualKey, keyCode, keyboarState, output, 2, 0, keyboardLayout))
-			return WString(output, 2);
+		int count = ToUnicodeEx(virtualKey, keyCode, keyboarState, output, 2, 0, keyboardLayout);
+		if (count > 0)
+			return WString(output, count);
 
 		return StringUtil::WBLANK;
 	}

+ 4 - 2
BansheeEngine/Source/BsShortcutManager.cpp

@@ -30,9 +30,11 @@ namespace BansheeEngine
 		UINT32 modifiers = 0;
 		if (Input::instance().isButtonHeld(BC_LSHIFT) || Input::instance().isButtonHeld(BC_RSHIFT))
 			modifiers |= (UINT32)ButtonModifier::Shift;
-		else if (Input::instance().isButtonHeld(BC_LCONTROL) || Input::instance().isButtonHeld(BC_RCONTROL))
+
+		if (Input::instance().isButtonHeld(BC_LCONTROL) || Input::instance().isButtonHeld(BC_RCONTROL))
 			modifiers |= (UINT32)ButtonModifier::Ctrl;
-		else if (Input::instance().isButtonHeld(BC_LMENU) || Input::instance().isButtonHeld(BC_RMENU))
+
+		if (Input::instance().isButtonHeld(BC_LMENU) || Input::instance().isButtonHeld(BC_RMENU))
 			modifiers |= (UINT32)ButtonModifier::Alt;
 
 		ShortcutKey searchKey((ButtonModifier)modifiers, event.buttonCode);

+ 6 - 0
MBansheeEditor/DebugWindow.cs

@@ -28,6 +28,12 @@ namespace BansheeEditor
             overlay.layout.AddElement(testExplicitBtn);
         }
 
+        [MenuItem("Window/Test", ButtonModifier.ShiftAlt, ButtonCode.A)]
+        private static void TestMenuItem()
+        {
+            ColorPicker.Show();
+        }
+
         void RefreshAssembly_OnClick()
         {
             Internal_RefreshAssembly();

+ 4 - 2
MBansheeEditor/MenuItem.cs

@@ -1,13 +1,15 @@
 using System;
+using BansheeEngine;
+
 namespace BansheeEditor
 {
     [AttributeUsage(AttributeTargets.Method)]
     public sealed class MenuItem : Attribute
     {
-        public MenuItem(string path, ShortcutKey shortcut, int priority = 0)
+        public MenuItem(string path, ButtonModifier shortcutModifier, ButtonCode shortcutKey,  int priority = 0)
         {
             this.path = path;
-            this.shortcut = shortcut;
+            this.shortcut = new ShortcutKey(shortcutModifier, shortcutKey);
             this.priority = priority;
         }
 

+ 1 - 0
TODO.txt

@@ -106,6 +106,7 @@ Other simple stuff:
  - Call stack from C# to use in Debug.Log calls
  - Get rid of event callback from HString and figure out a better way
  - GUI TextureField similar to ResourceField but it displays the texture it has assigned
+ - Getting rid of import on start would be a pretty big deal. Just adding a button in Editor "Reimport" should be good instead
 
 ----------------------------------------------------------------------
 Handles