The Trunk: Morphic-mt.1759.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-mt.1759.mcz

commits-2
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1759.mcz

==================== Summary ====================

Name: Morphic-mt.1759
Author: mt
Time: 25 April 2021, 3:42:18.642592 pm
UUID: 456105c7-734e-db41-8488-8d64c1c096e1
Ancestors: Morphic-mt.1758

Until we have a proper cross-platform mapping between virtual key codes to symbols (or characters), let the keyboard exerciser not deceive the user with a broken ad-hoc mapping. Just show the raw key code. This conforms to how a keyboard event's #printString looks like at the moment; it only shows key characters for keyStroke events, not keyUp or keyDown.

Note that, on some platforms, the keyDown for, e.g., CTRL will also raise the fitting modifier. Sometimes even more than that. Take a look at keyDown for SHIFT on Linux/X11.

=============== Diff against Morphic-mt.1758 ===============

Item was changed:
  ----- Method: KeyboardEvent>>asMorph (in category 'converting') -----
  asMorph
  "Answers a graphical reprsentation for this keyboard event. Does not work for keyUp and keyDown because we do not have platform-specific mapping tables for the key codes."
 
+ | box color |
- | box color hasModifiers |
  box := Morph new
  color: Color transparent;
  layoutPolicy: TableLayout new;
  listDirection: #leftToRight;
  hResizing: #shrinkWrap;
  vResizing: #shrinkWrap;
  cellGap: 2;
  yourself.
  color := self userInterfaceTheme get: #textColor for: #PluggableButtonMorph.
 
  self labelsForPhysicalModifiers
  do: [:modifier |
+ box addMorphBack: (ToolIcons keyboardButtonLabeled: modifier dyed: color) asMorph.
- hasModifiers := true.
- box addMorphBack: (ToolIcons keyboardButtonLabeled: modifier dyed: color) asMorph]
- separatedBy: [
  box addMorphBack: (('+' asText addAttribute: (TextColor color: color); asMorph) lock)].
+
-
- (self isKeystroke not
- and: [self keyValue between: 16 and: 18]
- and: [hasModifiers == true "some VMs are strange!!"])
- ifTrue: [ "keyUp and keyDown; just the raw modifier keys"
- ^ box].
-
- hasModifiers == true ifTrue: [
- box addMorphBack: (('+' asText addAttribute: (TextColor color: color); asMorph) lock)].
-
  (self keyValue between: 28 and: 31)
  ifTrue: [ "arrow keys"
  box addMorphBack: (ToolIcons keyboardButtonLabeled: (
  ScrollBar
  arrowOfDirection: (#(left right top bottom) at: self keyValue - 27)
  size: Preferences standardButtonFont height
  color: Color black) dyed: color) asMorph.
  ^ box].
 
+ box addMorphBack: (ToolIcons
+ keyboardButtonLabeled: (self isKeystroke
+ ifTrue: [self labelForPhysicalKeyStroke]
+ ifFalse: [self labelForPhysicalKeyDown])
+ dyed: color) asMorph.
- box addMorphBack: (ToolIcons keyboardButtonLabeled: self labelForPhysicalKey dyed: color) asMorph.
 
  ^ box!

Item was removed:
- ----- Method: KeyboardEvent>>labelForPhysicalKey (in category 'printing') -----
- labelForPhysicalKey
-
- ^ (self keyValue <= 32 or: [self keyValue = 127])
- ifFalse: [
- self keyCharacter asUppercase asString]
- ifTrue: [
- (self isKeystroke and: [self controlKeyPressed] and: [self keyValue < 28 "no arrows or space"])
- ifTrue: [
- "Most likely a physical key with a readable (uppercase) label. Be aware that this cannot cover the cases where the physical contro key was pressed together with the CTRL modifier."
- (self keyValue bitOr: 16r40) asCharacter asString "+64"]
- ifFalse: [
- self keyValue caseOf: {
- [ 1 ] -> [ 'Home' translated ].
- [ 4 ] -> [ 'End' translated ].
- [ 5 ] -> [ 'Insert' translated ].
- [ 8 ] -> [ 'Backspace' translated ].
- [ 9 ] -> [ 'Tab' ].
- [ 10 ] -> [ 'LF' ].
- [ 11 ] -> [ 'PageUp' translated ].
- [ 12 ] -> [ 'PageDown' translated ].
- [ 13 ] -> [ 'Return' translated "CR" ].
- [ 16 ] -> [ 'Shift' translated "Windows only?!!" ].
- [ 17 ] -> [ 'Ctrl' translated "Windows only?!!" ].
- [ 18 ] -> [ 'Alt' "Windows only?!!" ].
- [ 27 ] -> [ 'Esc' ].
- [ 32 ] -> [ 'Space' translated ].
- [ 127 ] -> [ 'Del' translated ].
- } otherwise: [
- 'ASCII-', (self keyValue printPaddedWith: $0 to: 2 base: 10)]]]!

Item was added:
+ ----- Method: KeyboardEvent>>labelForPhysicalKeyDown (in category 'printing') -----
+ labelForPhysicalKeyDown
+ "#keyDown and #keyUp -- needs platform-specific mapping for virtual key codes"
+
+ ^ 'VK-0x', (self keyValue printPaddedWith: $0 to: 2 base: 16)!

Item was added:
+ ----- Method: KeyboardEvent>>labelForPhysicalKeyStroke (in category 'printing') -----
+ labelForPhysicalKeyStroke
+
+ ^ (self keyValue <= 32 or: [self keyValue = 127])
+ ifFalse: [
+ self keyCharacter asUppercase asString]
+ ifTrue: [
+ (self controlKeyPressed and: [self keyValue < 28 "no arrows or space"])
+ ifTrue: [
+ "Most likely a physical key with a readable (uppercase) label. Be aware that this cannot cover the cases where the physical contro key was pressed together with the CTRL modifier."
+ (self keyValue bitOr: 16r40) asCharacter asString "+64"]
+ ifFalse: [
+ self keyValue caseOf: {
+ [ 1 ] -> [ 'Home' translated ].
+ [ 4 ] -> [ 'End' translated ].
+ [ 5 ] -> [ 'Insert' translated ].
+ [ 8 ] -> [ 'Backspace' translated ].
+ [ 9 ] -> [ 'Tab' ].
+ [ 10 ] -> [ 'LF' ].
+ [ 11 ] -> [ 'PageUp' translated ].
+ [ 12 ] -> [ 'PageDown' translated ].
+ [ 13 ] -> [ 'Return' translated "CR" ].
+ [ 27 ] -> [ 'Esc' ].
+ [ 32 ] -> [ 'Space' translated ].
+ [ 127 ] -> [ 'Del' translated ].
+ } otherwise: [
+ 'ASCII-', (self keyValue printPaddedWith: $0 to: 2 base: 10)]]]!

Item was changed:
  ----- Method: KeyboardExerciser>>logEvent: (in category 'event handling') -----
  logEvent: evt
 
  | eventMorph |
  eventMorph := evt asMorph.
  eventMorph
+ setProperty: #event toValue: evt copy;
+ balloonText: ('Click to inspect. Shift+click to explore.\\Key value: 0x{1} ({2}) \Key character: {3}\Virtual modifiers: {4}\Physical modifiers: {5}\\{6}' withCRs format: {
+ evt keyValue printPaddedWith: $0 to: 2 base: 16.
+ evt keyValue.
+ evt isKeystroke ifTrue: [evt keyCharacter printString] ifFalse: ['-'].
+ evt modifierString.
+ (evt labelsForPhysicalModifiers joinSeparatedBy: ' ') asUppercase.
+ evt printString}).
+
- balloonText: 'Click to inspect. Shift+click to explore.\\' withCRs, evt printString;
- setProperty: #event toValue: evt copy.
-
  eventMorph
  on: #mouseEnter send: #handleEvent:emphasize: to: self;
  on: #mouseLeave send: #handleEvent:deemphasize: to: self;
  on: #mouseDown send: #handleEvent:inspect: to: self.
 
  self addMorphBack: eventMorph.!

Item was changed:
  ----- Method: UserInputEvent>>modifierString (in category 'printing') -----
  modifierString
  "Return a string identifying the currently pressed modifiers"
  | string |
  string := ''.
+ self controlKeyPressed ifTrue:[string := string,'CTRL '].
+ self optionKeyPressed ifTrue:[string := string,'OPT '].
  self commandKeyPressed ifTrue:[string := string,'CMD '].
  self shiftPressed ifTrue:[string := string,'SHIFT '].
- self controlKeyPressed ifTrue:[string := string,'CTRL '].
  ^string!