OptionMobile()

Syntax

Result = OptionMobile(#Mobile, Text$, Group$ [, Flags])
Description
Create a mobile option in the current container.

Parameters

#Mobile A number to identify the new mobile object. #PB_Any can be used to auto-generate this number.
Text$ The label to use for the option.
Group$ The group identifier to use. Each option with the same group identifier will be linked together.
Flags (optional) If the current container is a 3 slots container, the following constants can be used to select in which slot the option should be created (an option can't be set in the center slot as it's always where the label will be displayed):
  #PB_Mobile_Left  : The option will be set in the left slot.
  #PB_Mobile_Right : The option will be set in the right slot.

Return value

Returns nonzero on success and zero on failure. If #PB_Any was used as the #Mobile parameter then the return-value is the auto-generated number on success.

Remarks

The following functions can be used to act on the button:

- SetMobileText(): Changes the label of the option.
- GetMobileText(): Returns the label of the option.
- SetMobileState(): Changes the state of the option (1 to activate the option, 0 to deactivate it).
- GetMobileState(): Returns the state of the option (1 if the option is active, 0 if not).

The following events are supported with EventType():
  - #PB_EventType_LeftClick: the option has been clicked.

Example

  If ContainerMobile(#PB_Any, #PB_Mobile_Page)
    ListMobile(0)
    If AddListMobileItem(0, "", #PB_Mobile_Container)
      OptionMobile(1, "Red", "Colors", #PB_Mobile_Left)
      CloseMobileContainer()
    EndIf
    If AddListMobileItem(0, "", #PB_Mobile_Container)
      OptionMobile(2, "Green", "Colors", #PB_Mobile_Left)
      CloseMobileContainer()
    EndIf
    If AddListMobileItem(0, "", #PB_Mobile_Container)
      OptionMobile(3, "Blue", "Colors", #PB_Mobile_Left)
      SetMobileState(3, #True) ; Selected by default
      CloseMobileContainer()
    EndIf
    
    CloseMobileContainer()
  EndIf

  Procedure MobileEvents()
    Select EventMobile()
      Case 1, 2, 3
        Debug "Option "+Str(EventMobile())+" clicked. State: " + GetMobileState(EventMobile())
    EndSelect
  EndProcedure

  BindEvent(#PB_Event_Mobile, @MobileEvents())

See Also

SetMobileText(), GetMobileText(), SetMobileState(), GetMobileState()

Supported OS

All

<- NavigatorMobile() - Mobile Index - ProgressBarMobile() ->