#! /usr/sgitcl/bin/moat xtAppInitialize xmMainWindow .main managed xmPushButton .main.button managed -labelString "Push me" . realizeWidget . mainLoop
Figure 4-1 : xmPushButton This is a regular button, displaying a text or pixmap label, surrounded by a beveled shadow. Clicking the button changes shadows to give the impression that the button has been pushed. When the button is released, it reverts to its normal appearance. When focus is gained, for instance by tabbing, the button appears brighter (if it is sensitive). The default push buttons of a dialog can be specified by setting -showAsDefault to true, in which case an additional border is drawn using Motif margin resources:
#! /usr/sgitcl/bin/moat xtAppInitialize xmMainWindow .main managed xmPushButton .main.b managed -labelString "Push me" -showAsDefault true . realizeWidget . mainLoop
Figure 4-2 : xmPushButton as Default Table 4-24 lists the resources for xmPushButton.
#! /usr/sgitcl/bin/moat xtAppInitialize xmBulletinBoard .top managed -width 110 -height 110 xmArrowButton .top.up managed -x 40 -y 10 -width 30 -height 30 xmArrowButton .top.left managed -x 10 -y 40 \ -width 30 -height 30 -arrowDirection arrow_left xmArrowButton .top.right managed -x 70 -y 40 \ -width 30 -height 30 -arrowDirection arrow_right xmArrowButton .top.down managed -x 40 -y 70 \ -width 30 -height 30 -arrowDirection arrow_down . realizeWidget . mainLoop
Figure 4-3 : xmArrowButton Table 4-25 lists the resources for xmArrowButton.
Resource Name | Default Value | Type or Legal Values |
---|---|---|
-arrowDirection | arrow_up | arrow_up arrow_down arrow_left arrow_right |
#! /usr/sgitcl/bin/moat xtAppInitialize xmMainWindow .main managed xmRowColumn .main.col managed -orientation vertical xmToggleButton .main.col.one managed xmToggleButton .main.col.two managed xmToggleButton .main.col.three managed . realizeWidget . mainLoop
Figure 4-4 : xmToggleButton A set of buttons can be grouped into a manager with the -radioBehavior resource set to true, ensuring that only one of them can be selected at a given time. Radio buttons are represented with diamonds instead of squares.
#! /usr/sgitcl/bin/moat xtAppInitialize xmMainWindow .main managed xmRowColumn .main.col managed -orientation vertical -radioBehavior true xmToggleButton .main.col.yes managed -set true xmToggleButton .main.col.no managed xmToggleButton .main.col.maybe managed . realizeWidget . mainLoop
Figure 4-5 : xmToggleButton with radioBehavior See the section "Manager Widgets" for more information about manager options. Table 4-26 lists the resources for xmToggleButton.
Text widgets also inherit resources from the Core, Primitive, and Label classes, as shown in Table 4-27.
In addition to the usual helpCallback and destroyCallback, button widgets define additional methods, as listed in Table 4-28.
Method name | Why |
---|---|
armCallback | Button pressed. |
disarmCallback | Button released, with the pointer still on it. |
activateCallback | Some event triggers the Activate function. |
The toggle button also defines the %set callback substitution, which is replaced by the Boolean state of the button.