[comp.sys.mac.hypercard] Faster keyboard processing from HyperCard

ulfis@nada.kth.se (Anders Ulfheden) (06/27/91)

I have developed a HyperCard stack with Communications ToolBox that contains
a terminal window. (Yes, I know that HyperCards is not the best platform for
this...)
The heart in the window is the idle loop that looks like

on idle
  ReadFromHost           -- Get output from host computer via CTB
  DisplayCharacters      -- Show characters in a HyperCard field
  -- pass idle           -- Don't pass idle deeper! Faster?
end idle

on keyDown whatkey
  if whatkey is ...      -- Check for specials, arrows etc
    -- special action taken here
  else
    SendToHost whatkey   -- Pass character to host via CTB
  end if
end keyDown

Unfortunately this is a slow way to handle keyboard input from the user,
especially if you make other things in the idle-loop too...

Wishful thinking would be a routine that can be installed for example during
openCard, and then removed during closeCard that traps keyboard input and
makes a direct call to CTB for sending the character. (Ok, special action as
in the keyDown routine above we maybe have to live without.) Maybe for certain
keys we can pass the keycode on to HyperCard for processing there...

on openCard
  installKeyboardRoutine
end openCard

on closeCard
  removeKeyboardRoutine
end closeCard

on keyDown whatkey
  -- We only get here if the keyboard routine doesn't handle the key
end keyDown

Is this possible to realize? Any suggestions or hints appreciated!

Ulfis
-- 
+------------------------------------------------------------------------------
|  Anders Ulfheden
|  USENET:  ulfis@nada.kth.se
|  Royal Institute of Technology

leonardr@sv.portal.com (Leonard Rosenthol) (07/01/91)

In article <1991Jun27.164506.27212@nada.kth.se>, ulfis@nada.kth.se (Anders Ulfheden) writes:
> I have developed a HyperCard stack with Communications ToolBox that contains
> a terminal window. (Yes, I know that HyperCards is not the best platform for
> this...)
> The heart in the window is the idle loop that looks like
> 
> [details removed to save space]
>
> Unfortunately this is a slow way to handle keyboard input from the user,
> especially if you make other things in the idle-loop too...
> 
> Wishful thinking would be a routine that can be installed for example during
> openCard, and then removed during closeCard that traps keyboard input and
> makes a direct call to CTB for sending the character. (Ok, special action as
> in the keyDown routine above we maybe have to live without.) Maybe for certain
> keys we can pass the keycode on to HyperCard for processing there...
> 
	If you are willing to go the route of XCMDs, then it is most certainly possible.  With HC 2.x and XWindows, an XCMD can request that it get all the keystrokes by making a BeginXWEdit callback.  Now all keystrokes will go to that X...If someone else wants to take the keyboard back, you will get an xGiveUpEdit event, which you could ignore and keep the keystrokes, though that might be sort of obnoxious.

Leonard Rosenthol

----------------------------------------------------------------------
+ Leonard Rosenthol                | AppleLink: MACgician            +
+ Software Ventures                | GEnie:     MACgician            +
+ Internet: leonardr@sv.portal.com | AOL:       MACgician            +
----------------------------------------------------------------------