> Date: Thu, 24 Aug 1995 08:49:26 +0000 > From: gasmit@facstaff.wm.edu (Gary A. Smith) > Subject: Re: Foreign characters in TBK3.0 > To: Chailerd Pichitpornchai >> > Hi, > > I would be interested in your Ctrl-2 handler for typing in > letters with diacritical marks. I have been looking for an efficient > way to get those upper-ASCII characters on the screen in some foreign > language programs I have written. I have devised a "buttonbar" > solution, where the user clicks on buttons whose captions are the > letters required for a specific language. But I haven't been able to > use this solution for input in request or ask boxes. Would your > handler solve that? > > +---------------------------------+----------------------------------+ > | Gary Smith | Voice: 804-221-3660 | > | Department of Modern Languages | FAX: 804-221-3637 | > | and Literatures | Email: gasmit@facstaff.wm.edu | > | College of William and Mary | | > | Williamsburg, VA 23187-8795 | | > +---------------------------------+----------------------------------+ > |"Wer immer strebend sich bemueht, den koennen wir erloesen" - Goethe| > | Rough translation: Just keep on trying, and you'll get your reward.| > +--------------------------------------------------------------------+ >
What you actually need are one lookup "Table" and 3 handlers described in (4) below. However, you need to create a couple of extra temporary fields to make life easier in creating the lookuup "Table".
Let's start...
Create a temporary button with the following handler.
Then execute it.
to handle buttonClick local string x sysLockScreen = true clear x step i from 128 to 255 x = x & i & " : " & ansiToChar(i) & crlf end text of field "Temp1" = x end
to handle keyDown key, isShift, isCtrl request "The scancode is" && key & "." forward end
base entry,1st lookup entry,2nd lookup entry,...Examples:
65,false,a,192,false,a,222,false,a,54,true,a,222,true,ae,... 65,true,A,192,false,[A-grave],222,false,[A-accent],... ...(add as many lookup table lines as you would like it to be)
The layout of the table will be as follows.
"a" with "'" (acute accent), "a" with "^" (circumflex), ... And in textLine 2, there will be those letters begun with the letter "e" "e" with "'" (acute accent), "e" with "^" (circumflex), ... And so on...
item1,item2,item3, item4,item5,item6, ... ^^^^^^^^^^^^^^^^^ (base entry) (lookup entry) Base entry ~~~~~~~~~~ The first 3 items will be the base entry or the base letter and they will be representing item1 = scancode (you get this number from trying typing in the field "Temp2", for example, the value for key "a" is 65) item2 = shift state ( false = lowercase "a" true = uppercase "a") item3 = base letter ( for example, the letter a) Lookup entry ~~~~~~~~~~~~ Each lookup entry will be composed of 3 items representing as follows. item4 = scancode (for example, the value for key "'" (accent) is 222) item5 = shift state (for example, when you want to put the umlaut, you have to press shift+' to get ") item6 = the actual letter that has diacritical mark with it (you copy and paste from field "Temp1") ** Example of textLine 1 of field "Table" for the base letter "a" 65,false,a,192,false,a,222,false,a,54,true,a,222,true,ae,... ** Explanation: 65,false,a is the base entry for lowercase "a" lookup table 192,false,[actual letter of an "a" with "`" (grave)] 222,false,[actual letter of an "a" with "'" (accent)] 54,true,[actual letter of an "a" with "^" (circumflex)] 222,false,[actual letter of an "a" with """ (double quote) to get the umlaut] ... To build the uppercase "A" with its diacritical marks, just copy the line in the example and modify according to the shift state as follows. 65,true,A,192,false,A,222,false,A,54,true,A,222,true,AE,... ** To build the lookup "Table" is not quite difficult as you expected because you just find the scancode the first time and then you can use them over and over. And you have to build this table just once. ----------------------------------------------------------------- (4). Now, this is the actual working part that you need to put into either the field, recordField, page, background, or book script (up to you). ---------------------------------------------------------------------- -- -- ** Copyright 1995 Chailerd Pichitpornchai, MD, PhD -- -- ** This is a freeware. Use with your own risks. -- -- ** Please acknowledge if you use these handlers in your -- applications. -- -- ** Last update: 26/08/95 -- ---------------------------------------------------------------------- -- Data Entry for letters with diacritical marks -- -- Handlers for entering letters with diacritical marks. -- Use a key combination of Ctrl-2 to flag the starting point of -- a sequence of following 2 keys combination. -- Then the user just press the 2 appropriate keys combination -- to produce the upper ASCII letters. -- For example, to type in an "a" with a circumfles "^" on top, -- the user will press Ctrl-2 then type the letter "a" and -- followed immediately by the letter "^" (pressing shift-6). -- If the user types in a nonexisting diacritical mark, the program -- will ignore the first key but print the second key instead. -- ---------------------------------------------------------------------- to handle keyDown key, isShift, isCtrl system string Table system logical Ctrl2 system int rowNumber Table = text of field "Table" conditions -- The Shift key is pressed for uppercase diacritics when key = keyShift break -- Start the 2 keys combination when isCtrl and key = key2 Ctrl2 = True -- set the "Ctrl2" flag rowNumber = 0 -- rowNumber 0 = start 2 keys combination -- 1 = 1 key has been entered -- -1 = 2 keys have been entered and -- finished -- in-between 2 keys combination when Ctrl2 = True and rowNumber = 0 -- see if the 1st key is in the Table result = isInTable(key, isShift) if item 1 of result = True then get flushMessageQueue() -- eat the 1st key stroke rowNumber = item 2 of result else Ctrl2 = False rowNumber = -1 end -- 2 keys have been entered when Ctrl2 = True and rowNumber > 0 aRow = textLine rowNumber of Table step i from 4 to itemCount(aRow) by 3 keyShiftPressed = item i+1 of aRow if (key = item i of aRow) and (isShift = keyShiftPressed) rowNumber = -1 get flushMessageQueue() -- eat the 2nd key stroke -- print diacritics send keyChar CharToAnsi(item i+2 of aRow) Ctrl2 = False -- reset the flag found = True break step end end if found <> True then -- the second key is not in the table Ctrl2 = False -- ToolBook will print the 2nd key rowNumber = -1 end else -- normal key forward end end to get isInTable k, isS system string Table step i from 1 to textLineCount(Table) get textLine i of Table if (k = item 1 of It) and (isS = item 2 of It) then return True, i break step end end return False end to handle keyChar key, isShift, isCtrl system logical Ctrl2 system int rowNumber conditions -- In-between 2 key combinations when Ctrl2 = True and rowNumber > 0 -- eat the keystroke -- Complete the 2 keys combination when Ctrl2 = True and rowNumber = -1 -- print the diacritics forward -- Normal key else forward end end ====================================================================== The above mentioned method is a minor part of my work that I will be presenting at the World Developers' Conference '95 which will be held during 11-13 September. My presentation title is "QED Tutorial Outliner & Template - Flexible Authoring with Mechanistic Simulation" and it is scheduled for Monday, September 11th at 4.30pm in the Crossroads room in the Bellevue Red Lion Hotel, Washington. If any of you happens to come to the meeting, you will be very welcome to drop by and discuss with me at the presentation or at the meeting. I will be absent from the list for a month in September because I will be flying to Auckland, New Zealand this upcoming Thursday to give a 2-day Multimedia ToolBook training course organised by local Asymetrix distributors in NZ. Then I will be heading to the Conference and the holidays in the west coast of USA. I'm really looking forward to attending this exciting Conference!!! Talk to you all soon. Chailerd. *************************************************** Chailerd Pichitpornchai, MD, PhD Research Fellow, ToolBook Consultant Quality Education at a Distance (QED) Research Unit Monash University, Australia. Tel: (61-3) 9905-9141 Fax: (61-3) 9905-2891 * Asymetrix Authorised Training Center * email: chailerd@qed.monash.edu.au ***************************************************