Shortcut.FromKey() now uses an internal cache.
[GB.GUI.BASE] * OPT: Shortcut.FromKey() now uses an internal cache.
This commit is contained in:
parent
6364bd1376
commit
4eb38b4c07
2 changed files with 20 additions and 10 deletions
|
@ -7,7 +7,6 @@ Public Const _Properties As String = "*,Border=True,ScrollBar{Scroll.*}=Both,Foc
|
|||
Public Const _DefaultEvent As String = "Draw"
|
||||
Public Const _DefaultSize As String = "24,24"
|
||||
Public Const _Similar As String = "DrawingArea,ScrollView"
|
||||
'Public Const _Group As String = "View"
|
||||
|
||||
Property ScrollX As Integer
|
||||
Property ScrollY As Integer
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
Export
|
||||
|
||||
Static Private $cNameFromKey As Collection
|
||||
|
||||
Static Public Sub _call(Text As String, Shortcut As String, Optional AddIfMissing As Boolean) As String
|
||||
|
||||
Dim iPos As Integer
|
||||
|
@ -29,21 +31,30 @@ Static Public Sub FromKey() As String
|
|||
Dim sShortcut As String
|
||||
Dim sSymbol As String
|
||||
Dim hClass As Class
|
||||
Dim sName As String
|
||||
|
||||
If Key.Control Then sShortcut &= "Ctrl+"
|
||||
If Key.Shift Then sShortcut &= "Shift+"
|
||||
If Key.Alt Then sShortcut &= "Alt+"
|
||||
If Key.Meta Then sShortcut &= "Meta+"
|
||||
|
||||
hClass = Classes["Key"]
|
||||
For Each sSymbol In hClass.Symbols
|
||||
With hClass[sSymbol]
|
||||
If .Kind = Class.Constant And If .Value = Key.Code Then
|
||||
Return sShortcut & .Name
|
||||
Endif
|
||||
End With
|
||||
Next
|
||||
If Not $cNameFromKey Then
|
||||
|
||||
Return sShortcut & String.Chr(Key.Code)
|
||||
$cNameFromKey = New Collection
|
||||
hClass = Classes["Key"]
|
||||
For Each sSymbol In hClass.Symbols
|
||||
With hClass[sSymbol]
|
||||
If .Kind = Class.Constant Then $cNameFromKey[.Value] = .Name
|
||||
End With
|
||||
Next
|
||||
|
||||
Endif
|
||||
|
||||
sName = $cNameFromKey[Key.Code]
|
||||
If sName Then
|
||||
Return sShortcut & sName
|
||||
Else
|
||||
Return sShortcut & String.Chr(Key.Code)
|
||||
Endif
|
||||
|
||||
End
|
||||
|
|
Loading…
Reference in a new issue