Common Desktop Environment: Desktop KornShell User's Guide

Setting Widget Translations

dtksh provides mechanisms for augmenting, overriding, and removing widget translations, much as in the C programming environment. In C, an application installs a set of translation action procedures, which can then be attached to specific sequences of events (translations are composed of an event sequence and the associated action procedure). Translations within dtksh are handled in a similar fashion, except only a single action procedure is available. This action procedure, named ksh_eval, interprets any parameters passed to it as dtksh commands and evaluates them when the translation is triggered. The following shell script segment gives an example of how translations can be used:

BtnDownProcedure() 
{   
		echo "Button Down event occurred in button "$1 
} 
XtCreateManagedWidget BUTTON1 button1 XmPushButton $PARENT \
      labelString:"Button 1" \       
			translations:'#augment
              <EnterNotify>:ksh_eval("echo Button1 entered")
              <Btn1Down>:ksh_eval("BtnDownProcedure 1")'
XtCreateManagedWidget BUTTON2 button2 XmPushButton $PARENT \      
			labelString:"Button 2" 
XtOverrideTranslations $BUTTON2 \            
				'#override
         <Btn1Down>:ksh_eval("BtnDownProcedure 2")'