Control : Button

Back to Controls

Buttons provide a user interface for executing functions. Button types include: Button, StyleButton, LinkFunctionLabel, ImageButton, OK, Cancel, OK Style and Cancel Style.

 

Contents

Examples

The following examples are intended to be used with sample code that you can import into your Bungee Builder workspace from the Start Page. Each example is intended to build upon the previous example to provide you with a complete understanding of how to use this control.

Example 1: Four Button Controls Bound to the Same Function (Ex1_CurrentTime)

In this example, all four buttons are bound to the same function (getCurrentTime). The function sets a dateTime field (currentTime) to the current time.

In the Model-View-Adapter diagram for this example, each of the four types of button control is bound to the getCurrentTime function by its own control adapter. Similarly, the Label control is bound by a Control Adapter to the currentTime field.

Click for larger image  Run Now

Example 2: Displays a Popup Dialog (Ex2_PopupDialog)

You can use a button to open a dialog window, including custom forms that you have created. In order to do so, you can use the open dialog statement in the function to which the button is bound.

In this example, the showPerson function invokes the open dialog BungeeLogic statement to display a form in a popup dialog. In the function, the open dialog statement has been set to display the form in either a Modal state (no other windows can receive focus during the life of the popup) or Normal state (other windows can receive focus) according to the state of a checkbox on the main form.

Using a popup dialog also shows how you can use the OK and Cancel button controls. The OK, Cancel, OK Style and Cancel Style buttons are Button controls that have the Button Label property set to "OK" or "Cancel" by default and the Close Form property selected by default. When you select the Is Modal checkbox on the main form, the closeResult label will display the value returned to the showPerson function when the popup dialog is closed. You can use the value returned in the open dialog's Close Result property to determine if the end user clicked OK or Cancel on the popup dialog.

As in the previous example, all four buttons are bound to the same function. Because each button derives its functionality from the logic in the function, the Model-View-Adapter diagram for the buttons in this example is almost exactly the same as the previous example.

Click for a larger image  Run Now

Example 3: Passing Parameters to the Function (Ex3_Parameters)

When you bind a button to a function that has arguments, you can define arguments for the button to pass to the function in the Button's Parameters property (Behavior tab).

In this example, the setFruit function allows an input argument ([in] string newFruit) to set the value on the fruit field. For each button, the parameter is set to a different fixed value (Apple, Orange, Grape, and Pear). You can also set the values dynamically by using a field or other path.

Click for a larger image  Run Now

Example 4: State Management, Changing Button Text, and Tooltip (Ex4_Misc)

You can control button behavior and appearance by setting properties on the button and on the function to which it's bound. This example shows several properties that buttons support:

Button Properties 

Function Property

  • State, Show—Sets whether or not the button is visible
  • State, Enable—Sets whether or not the button is enabled 

Note Show and Enable are set on the function to enable you to programatically manage the state of all buttons bound to the same function throughout your application. 

Click for a larger image  Run Now

Example Helper Classes

Person

Click for a larger image  Run Now

Reference

Supported Types (Control Adapter)

Type Summary
Function Function is a defined type that represents a runtime function. In BungeeConnect, a function is another member of a class like field; function is special only in that function represents a statement block of Bungee Logic that can be executed when invoked at runtime on an object instance. Function signatures of any kind are function types that you can tie to any of the 4 buttons described above.

Property Adapters

Name Summary
Tooltip Displays the tooltip as the user moves the mouse over the Button.
Bound Label, Text Allows you to dynamically modify the display text for any button that displays Text (button's 1-3 above). For example, if the associated field value on the server changes, then the button dynamically displays the new text.

Connection Adapters

Name Default Summary

NA 

   

Function Adapters

Name Default Summary
Drag Function 

<not set>

 

Users can drag an object from any control that supports drag and drop. For example, if the button is a "purchase" operation, then the user could potentially drop a list of items to purchase on the button which would invoke this function adapter that could conditionally call the actual "purchase" function assuming the adapter validates the dropped objects.

Validate Close 

<not set>

If the Validate Close function adapter below is set to true, and the adapter has been set, then the adapter looks for a function with the matching function adapter set on it (to validate if close on execute applies to the form that is the parent container of the button).

Function Adapter: Drag Function

Field Type Field Name Description
NA    

Function Adapter: Validate Close

Field Type Field Name Description
[out] boolean  canClose  A boolean out parameter that when set to true, alerts the button control that closing the window associated with the button is allowed.  canClose = True if it is ok to close the window, canClose = False if the action cannot cause the parent window to close.

Associated Properties

Common Properties Index

Specialized Properties

Unique Properties

  • None

 


Log in if you would like to rate this page.
    Copyright © 2005 - 2007 Bungee Labs. All rights reserved.