Topic: APLX Help : System Classes : List of Classes : Button
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

Button


Description

The Button class implements the command button objects, like the OK and Cancel buttons found in many dialogs. You typically set the caption property which indicates the caption associated with the control, and you might set the enabled property to 1 or 0 depending on whether a particular option is valid (for example, an OK button might be disabled unless the user has entered some valid text in an Edit field)

For Buttons, you will always want to define an onClick callback, which is invoked when the button is pressed, and which in many cases will close the dialog. For most dialogs, you should define one of your buttons (typically the OK button or equivalent) to have a style property of 1, which means that it is the default button which ends the dialog. Buttons with a style of 1 are outlined in a heavy line, and respond to the Enter or Return key as well as to mouse clicks. In addition, you may wish to have a second button with a style of 2, which means that it is a Cancel style button which responds to the Escape or (under MacOS) Command-period key.

To provide help text when the user moves the mouse pointer over the control and pauses, you can use the tooltip property.

See also the ToolButton class, which provides a different kind of button on which you can place an image as well as or instead of text.

Example

     ∇DEMO_Button;DEMO
[1]   ⍝ Sample function demonstrating use of the Button object
[2]   DEMO←'⎕' ⎕NEW 'Dialog' ⋄ DEMO.where←5 10 ⋄ DEMO.scale←1 ⋄ DEMO.size←10 46
[3]   DEMO.title←'Button Example'
[4]   ⍝
[5]   ⍝ CREATE OK BUTTON
[6]   DEMO.OK.New 'Button'
[7]   DEMO.OK.style←1
[8]   DEMO.OK.where←2 5 2 12
[9]   DEMO.OK.caption←'I''m OK'
[10]  DEMO.OK.tooltip←'Press this button if you are feeling fine today'
[11]  DEMO.OK.onClick←'⎕←''OK Hit!'''
[12]  ⍝
[13]  ⍝ CREATE CANCEL BUTTON
[14]  DEMO.CANCEL.New 'Button'
[15]  DEMO.CANCEL.style←2
[16]  DEMO.CANCEL.where←2 20 2 20
[17]  DEMO.CANCEL.caption←'You''re Cancelled'
[18]  DEMO.CANCEL.tooltip←'Want to cancel something? Now is your chance'
[19]  DEMO.CANCEL.onClick←'⎕←''Cancel Hit!'''
[20]  ⍝
[21]  ⍝ Wait for the user to close the window
[22]  0 0⍴⎕WE DEMO
     ∇

Properties

align anchors aquaadjust autodraw caption children class color data doublebuffered dragsource droptarget enabled events extent font handle maxsize methods minsize name opened order pointer properties scale self size sourceformats style tabstop targetformats tie tooltip units visible where winptr

Methods

Click Clienttoscreen Close Create Delete Draw Focus Hide New Open Paint Resize Screentoclient Send Set Show Trigger

Callbacks

onClick onClose onDblClick onDestroy onDragDrop onDragEnd onDragEnter onDragLeave onDragOver onDragStart onFocus onHide onKeyDown onKeyPress onKeyUp onMouseDown onMouseMove onMouseUp onOpen onSend onShow onUnFocus


Topic: APLX Help : System Classes : List of Classes : Button
[ Previous | Next | Contents | Index | APL Home ]