Member variable XbpStatusBarPanel():key Foundation

Specifies a key string that uniquely identifies a XbpStatusBarPanel object.

Attribute: EXPORTED
Data type: Character ("")
Description

The :key instance variable contains a character string that can be used to uniquely identify a panel object within its XbpStatusBar container. While the ordinal position of a statusbar panel may change as panels are added or deleted at run time, a panel's key string must be unique over the lifetime of the statusbar object. If an attempt is made to add a panel with a duplicate key string, or if the key of an existing panel is to be set to a duplicate value, a runtime value is generated.

The key string assigned to a given XbpStatusBarPanel object can be specified using the <cKey> parameter to XbpStatusBar:addItem(). Alternatively, a panel's :key instance variable may be used to change its key string after it has already been added to an XbpStatusBar instance.

Using key strings versus ordinal item positions can greately enhance source code maintenance and readability.

// 
// Example for using :key to distinguish between statusbar 
// panels in an event handler 
// 
#include "XBP.CH" 

PROCEDURE Main() 
  LOCAL oSBar, oPanel 

    // Create an XbpStatusBar object with two 
    // status bar panels. Use a callback code 
    // block to react to "PanelClick" events 
    oSBar := XbpStatusBar():new() 
    oSBar:create( ,, {0,0}, {SetAppWindow():currentSize()[1],30} ) 

    osbar:panelClick := {|oPanel| HandleClick(oPanel) } 

    oPanel           := oSBar:getItem( 1 ) 
    oPanel:caption   := "Panel #1" 
    oPanel:key       := "PANEL1" 

    oPanel           := oSBar:addItem() 
    oPanel:caption   := "Panel #2" 
    oPanel:key       := "PANEL2" 
    oPanel:autoSize  := XBPSTATUSBAR_AUTOSIZE_SPRING 

    WAIT "Please click a status bar panel or press a key." 
 RETURN 


 // Process "PanelClick" event. Use the :key 
 // instance variable to determine which panel 
 // has been clicked on 
 PROCEDURE HandleClick( oPanel ) 

    IF oPanel:key == "PANEL1" 
       MsgBox( "Panel #1 was clicked" ) 
    ELSEIF oPanel:key == "PANEL2" 
       MsgBox( "Panel #2 was clicked" ) 
    ENDIF 

 RETURN 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.