The VkRepeatButton class, derived from VkComponent, provides an auto-repeating pushbutton. A regular pushbutton activates only once when the user clicks on and releases it. A VkRepeatButton (similar to a scrollbar button) activates when the user clicks on it, and after a given delay, begins repeating at a given interval. It stops activating when the user releases it.
Repeating Button Constructor
The VkRepeatButton constructor takes three arguments:
name is a character string specifying the component name. parent is the parent widget of the component. type is a VkRepeatButtonType enumerated value specifying the type of button to create. This value can be any of RB_pushButton, RB_pushButtonGadget, RB_arrowButton, or RB_arrowButtonGadget. These create PushButton, PushButtonGadget, ArrowButton, and ArrowButtonGadget widgets, respectively.
Responding to Repeat Button Activation
A VkRepeatButton object triggers a VkRepeatButton::buttonCallback ObjectPak callback when the button activates. Any ObjectPak object can register a member function with the callback to be invoked when the button activates.
The callback provides an XmAnyCallbackStruct pointer as call data; the XmAnyCallbackStruct.reason contains the reason for the callback, and the XmAnyCallbackStruct.event field contains the event that triggered the callback.
Repeating Button Utility and Access Functions
The VkRepeatButton::setParameters() function changes the delay parameters for the button:
- void setParameters(long initial, long repeat)
initial controls how long, in milliseconds, the user has to hold the button down before it begins to repeat. repeat controls the interval between auto-repeat activations, in milliseconds.
If you need to determine the type of a VkRepeatButton after creation, you can call the VkRepeatButton::type() function:
- VkRepeatButtonType type()
The return value is a VkRepeatButtonType enumerated value specifying the type of button. This value can be any of RB_pushButton, RB_pushButtonGadget, RB_arrowButton, or RB_arrowButtonGadget, which indicates PushButton, PushButtonGadget, ArrowButton, and ArrowButtonGadget widgets, respectively.
X Resources Associated with Repeating Button
The VkRepeatButton class provides the following X resources that determine operating characteristics of the component:
initialDelay Initial delay in milliseconds before auto-repeat begins (default value 1000)
repeatDelay Auto-repeat interval in milliseconds (default value 200)