This code adds a translation to turn an arrow left or right when the l or r key is typed:
#! /usr/sgitcl/bin/moat xtAppInitialize xmArrowButton .arrow managed .arrow setValues -translations \ {<Key>r: action(arrow_direction %w arrow_right) <Key>l: action(arrow_direction %w arrow_left) } proc arrow_direction {arrow direction} { puts stdout "Changing direction to $direction" $arrow setValues -arrowDirection $direction } . realizeWidget . mainLoopAs with callbacks, substitutions are possible. The only one currently supported is
%w
, to substitute the current widget path. Other substitutions return an error message.