/
KMModifiedKeyCombination.class.st
141 lines (112 loc) · 2.91 KB
/
KMModifiedKeyCombination.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
"
I represent key combinations combining a single key + a modifier.
The modifier could be a single modifier key (look at my subclasses) or a combination of them. For example, valid modified key combinations could be:
- shift + a
- ctrl + shift + c
To create a modified key combinations use the #command, #alt, #control or #shift messages. Like for example:
$a command
$b shift
$1 control
$z alt
"
Class {
#name : #KMModifiedKeyCombination,
#superclass : #KMKeyCombination,
#instVars : [
'modifier',
'character'
],
#category : #'Keymapping-KeyCombinations'
}
{ #category : #'instance creation' }
KMModifiedKeyCombination class >> modifier: aModifier character: aCharacter [
^ (self new)
modifier: aModifier;
character: aCharacter;
yourself
]
{ #category : #comparing }
KMModifiedKeyCombination >> = aShortcut [
super = aShortcut
ifFalse: [ ^ false ].
modifier = aShortcut modifier
ifFalse: [ ^ false ].
aShortcut character = character
ifFalse: [ ^ false ].
^ true
]
{ #category : #combining }
KMModifiedKeyCombination >> alt [
^ self modifiedBy: KMModifier alt
]
{ #category : #matching }
KMModifiedKeyCombination >> beginsWith: aKMShortcut [
^ self = aKMShortcut
]
{ #category : #accessing }
KMModifiedKeyCombination >> character [
^ character
]
{ #category : #accessing }
KMModifiedKeyCombination >> character: aCharacter [
character := aCharacter.
]
{ #category : #combining }
KMModifiedKeyCombination >> command [
^ self modifiedBy: KMModifier command
]
{ #category : #combining }
KMModifiedKeyCombination >> control [
^ self modifiedBy: KMModifier ctrl
]
{ #category : #combining }
KMModifiedKeyCombination >> ctrl [
^ self control
]
{ #category : #comparing }
KMModifiedKeyCombination >> hash [
^ character hash + modifier hash
]
{ #category : #accessing }
KMModifiedKeyCombination >> key [
^ self character key.
]
{ #category : #matching }
KMModifiedKeyCombination >> matchesEvent: aKeyboardEvent [
^ (self modifier matchesEvent: aKeyboardEvent)
and: [self character matchesEvent: aKeyboardEvent]
]
{ #category : #combining }
KMModifiedKeyCombination >> meta [
^ self modifiedBy: KMModifier meta
]
{ #category : #combining }
KMModifiedKeyCombination >> modifiedBy: aModifier [
^self character asKeyCombination modifiedBy: modifier + aModifier.
]
{ #category : #accessing }
KMModifiedKeyCombination >> modifier [
^ modifier
]
{ #category : #accessing }
KMModifiedKeyCombination >> modifier: aModifier [
modifier := aModifier
]
{ #category : #'accessing - platform' }
KMModifiedKeyCombination >> platformCharacter [
^ self character key
]
{ #category : #'accessing - platform' }
KMModifiedKeyCombination >> platformModifier [
^ self modifier
]
{ #category : #printing }
KMModifiedKeyCombination >> printOn: aStream [
modifier printOn: aStream.
aStream << ' + '.
character printOn: aStream.
]
{ #category : #combining }
KMModifiedKeyCombination >> shift [
^ self modifiedBy: KMModifier shift
]