pbEnabled - cCJAction

Detrmines if an item is enabled

Type: Property

Access: Read/Write

Data Type: Boolean

Parameters: None

Syntax
 Property Boolean pbEnabled

Read Access: Get pbEnabled to BooleanVariable
Write Access: Set pbEnabled to BooleanVariable/Value


Description

pbEnabled determines if an item is enabled. This is typically used to enable or disable menu items and toolbar items. When set to true, the item will appear with an enabled appearance. When set to false, the item will appear disabled and you will not be able to select the item.

Default value is true.

Although this can be used to set the enabled state of an item, you will normally only get the value of this property. Augmenting the IsEnabled function and relying on the Update method is the preferred method for setting an item's enabled state.

Samples

This will toggle the enabled state of an item every time it is executed.

// not recommended
Procedure OnExecute
    Boolean bEnabled
    Get pbEnabled to bEnabled
    Set pbEnabled to (not(bEnabled))
End_Procedure 

This above sample is not realistic. An item's enabled state is usually determined by the value of some external property. A method of coding this might be:

// still not recommended
Procedure OnExecute
    Boolean bEnabled
    Get pbSomeExternalPropertyValue to bEnabled
    Set pbSomeExternalPropertyValue  to (not(bEnabled))
    Set pbEnabled to (not(bEnabled))
End_Procedure 

The above is still not the best way to control an item's enabled state. The IsEnabled function provides an alternate way to determine if an item is enabled. The following example shows the best way of controlling an item's enabled state.

// recommended
Procedure OnExecute
    Boolean bEnabled
    Get pbSomeExternalPropertyValue to bEnabled
    Set pbSomeExternalPropertyValue  to (not(bEnabled))
End_Procedure

Function IsEnabled returns Boolean
    Boolean bEnabled
    Get pbSomeExternalPropertyValue to bEnabled
    Function_Return bEnabled
End_function

See Also

IsEnabled | Update | pbActiveUpdate