mapCmdWindow.py (2759B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\mapCmdWindow.py 2 import localization 3 from carbonui import uiconst 4 from carbonui.primitives.containerAutoSize import ContainerAutoSize 5 from carbonui.uicore import uicore 6 from eve.client.script.ui.control import eveLabel 7 from carbonui.control.button import Button 8 from carbonui.control.window import Window 9 10 class MapCmdWindow(Window): 11 __guid__ = 'form.MapCmdWindow' 12 default_fixedWidth = 320 13 default_state = uiconst.UI_NORMAL 14 default_windowID = 'MapCmdWindow' 15 16 def ApplyAttributes(self, attributes): 17 Window.ApplyAttributes(self, attributes) 18 cmdname = attributes.cmdname 19 self.SetCaption(uicore.cmd.FuncToDesc(cmdname)) 20 self.MakeUnResizeable() 21 self.mouseCookie = uicore.event.RegisterForTriuiEvents(uiconst.UI_MOUSEUP, self.OnGlobalMouseUp) 22 self.keyCookie = uicore.event.RegisterForTriuiEvents(uiconst.UI_KEYUP, self.OnGlobalKeyUp) 23 currShortcut = uicore.cmd.GetShortcutStringByFuncName(cmdname) or localization.GetByLabel('UI/Common/None') 24 self._content = ContainerAutoSize(parent=self.GetMainArea(), align=uiconst.TOTOP, callback=self._OnContentResized) 25 eveLabel.EveLabelMedium(parent=self._content, align=uiconst.TOTOP, state=uiconst.UI_DISABLED, text=localization.GetByLabel('UI/Commands/EnterNewShortcutPrompt', currShortcut=currShortcut)) 26 Button(parent=ContainerAutoSize(parent=self._content, align=uiconst.TOTOP, padTop=16), align=uiconst.CENTER, label=localization.GetByLabel('UI/Common/Cancel'), func=self.Close, args=None) 27 28 def _OnContentResized(self): 29 content_height = self._content.height + self._content.padTop + self._content.padBottom 30 _, self.height = self.GetWindowSizeForContentSize(height=content_height) 31 32 def OnGlobalMouseUp(self, window, msgID, param): 33 btnNum, type = param 34 btnMap = {uiconst.MOUSEMIDDLE: uiconst.VK_MBUTTON, 35 uiconst.MOUSEXBUTTON1: uiconst.VK_XBUTTON1, 36 uiconst.MOUSEXBUTTON2: uiconst.VK_XBUTTON2} 37 if btnNum in btnMap: 38 self.Apply(btnMap[btnNum]) 39 40 def OnGlobalKeyUp(self, window, msgID, param): 41 vkey, type = param 42 self.Apply(vkey) 43 44 def Confirm(self, *args): 45 pass 46 47 def Apply(self, vkey): 48 shortcut = [] 49 for modKey in uiconst.MODKEYS: 50 if uicore.uilib.Key(modKey) and modKey != vkey: 51 shortcut.append(modKey) 52 53 shortcut.append(vkey) 54 self.result = {'shortcut': tuple(shortcut)} 55 self.SetModalResult(1) 56 57 def _OnClose(self, *args): 58 uicore.event.UnregisterForTriuiEvents(self.mouseCookie) 59 uicore.event.UnregisterForTriuiEvents(self.keyCookie)