home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wmchar.zip / WMCHAR.CPP
Text File  |  2002-11-10  |  3KB  |  65 lines

  1. wmChar: wParam with: lParam
  2.     "Private - Processes WM_CHAR messages."
  3.   | result text |
  4.  
  5.   "Extract the character from WPARAM and put it in LastKey."
  6.   (result := super wmChar: wParam with: lParam) == nil
  7.     ifFalse: [
  8.       LastKey > 16rFF ifTrue: [super peekChar].
  9.       ^result].
  10.  
  11.   "If the receiver is running on a double byte platform,
  12.   disable certain control key combinations because they
  13.   interfere with the character count."
  14.   OSWidget isDBPlatform ifTrue: [
  15.     (OS getKeyState: VkControl) < 0 ifTrue: [
  16.       LastKey == VkBack ifTrue: [^0].  "Ctrl+Bs"
  17.       LastKey == Lf value ifTrue: [^0].  "Ctrl+Enter"
  18.       LastKey == VkTab ifTrue: [^0].  "Ctrl+Tab"
  19.       LastKey == VkReturn ifTrue: [^0].  "Ctrl+Enter"
  20.       LastKey == $h value ifTrue: [self adjustBackspace].  "Ctrl+h"
  21.       LastKey == $v value ifTrue: [self paste.  ^0].  "Ctrl+V"
  22.       LastKey == $x value ifTrue: [self cut.  ^0].  "Ctrl+X"
  23.       LastKey == $z value ifTrue: [^0].  "Ctrl+Z"
  24.       LastKey == Del value  ifTrue: [^0]]].  "Ctrl+Del"
  25.  
  26.   "Process the OSxActivate event."
  27.   LastKey == VkReturn ifTrue: [
  28.     (self hooksActivate and: [self isSingleLine or: [self isAligned]])
  29.       ifTrue: [self postEvent: OSxActivate.  ^0].
  30.     self isAligned ifTrue: [^0]].
  31.  
  32.   "Bug in Windows.  When the receiver is a single-line
  33.   text widget, when the user presses return or escape,
  34.   Windows beeps.  The fix is to look for VK_RETURN
  35.   and VK_ESCAPE and not call the text window proc."
  36.   (self isSingleLine or: [self isAligned]) ifTrue: [
  37.     LastKey == VkReturn ifTrue: [^0].
  38.     (parent isComboBox and: [parent isDropped])
  39.       ifFalse: [LastKey == VkEscape ifTrue: [^0]]].
  40.  
  41.   "Process the OSxVerify event."
  42.   self hooksVerify ifTrue: [
  43.     (LastKey == VkReturn and: [self isSingleLine]) ifTrue: [^result].
  44.     (self verifyCharacter: LastAscii asCharacter) ifTrue: [
  45.       LastKey > 16rFF ifTrue: [super peekChar].  ^0]].
  46.  
  47.   "If we are on a double byte platform, adjust the encoding and
  48.   update the character count based on the character that was
  49.   typed."
  50.   self readOnly ifFalse: [
  51.     OSWidget isDBPlatform ifTrue: [
  52.       text := LastAscii asCharacter asString.
  53.       self updateEncoding: text.
  54.                                                      
  55.       self isEncoded ifTrue: [
  56.      LastKey == VkBack
  57.        ifTrue: [self adjustBackspace]
  58.        ifFalse: [
  59.          (LastKey == VkTab or: [LastKey == VkReturn or: [LastAscii >= 16r20]])
  60.            ifTrue: [result := self adjustCharacter: LastAscii asCharacter]]]]].
  61.  
  62.   "Check if the OSxActivate event was sent."
  63.   result == 0 ifTrue: [LastKey > 16rFF ifTrue: [super peekChar]].
  64.   ^result
  65.