Loading
Salesforce now sends email only from verified domains. Read More
Help Agent Performance DegradationRead More
Visual Studio Code Based Modeler for Consumer Goods Cloud
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Support for Long Press of Buttons

          Support for Long Press of Buttons

          Consumer Goods Cloud Mobile App Framework displays a context menu when a user presses a button in a list for more than 0.5 seconds.

          Required Editions

          Available in: Lightning Experience in Professional, Unlimited, and Enterprise Editions that have Consumer Goods Cloud enabled.

          The context menu options are actions defined based on the purpose of using the button in the list. You can define different context menu options for buttons with different bindingId. For example, if a camera button is used within a list and long press is enabled for this button, the context menu can display the options add picture from gallery, remove picture, and sketch picture. This feature is possible only by using an element, LongPressMenu, within the list controls that support the Button binding element type. In addition, the Button binding element type must include an additional attribute, longPressMenuId.

          Note
          Note The LongPressMenu element has the same model as the ContextMenu element. If the longPressMenuId attribute isn’t defined in the Button binding element type for a button, the context menu isn’t displayed on long press of that button.

          Mobile Theming Support

          Mobile theming support is available for the LongPressMenu element. The theming configuration settings for defining the color properties of the ContextMenu UI component are also applicable for the LongPressMenu element. This implies that the color changes made to the ContextMenu component are also visible for the LongPressMenu element.

          Attributes of the LongPressMenu Element

          The table lists the attributes that are available for the LongPressMenu element.

          Attribute Description Values or Pattern Required?
          name Unique name of the element. The name must match one of the values defined for the longPressMenuId attribute. String Yes
          dataSource Data binding path linked to the LongPressMenu element. Data resource Yes

          Subelement of the LongPressMenu Element

          The LongPressMenu element can contain the Items element.

          Subelement of the Items Sub Element

          The Items element can contain the Bindings element.

          Binding Targets of the Items Subelement

          The table lists the binding targets that are available for the Items element.

          Target Description Type Required?
          Icon Defines the icon of a context menu item. Image Yes
          Text Defines the text of a context menu item. Label Yes
          Editable Indicates whether the entries in the control are editable. By default, the entries are editable. Editable Optional
          Visible Indicates whether the control is visible. By default, the control is visible. Visible Optional
          Note
          Note
          • CG Cloud Mobile App Framework implicitly adds bindingId of the long-pressed button as a parameter to the LongPressMenuOpeningEvent event.
          • The longPressMenuId attribute can be used only if the binding type is set to Button.
          • If the LongPressMenu element is defined within a list control, the LongPressMenuSelectedEvent event must be declared. If this event isn’t declared, then a Framework warning is triggered.
          • The value of the longPressMenuId attribute must match the name of a LongPressMenu element defined in the same contract.

          Long Pressed Button Context Menu

          Example
          Example
          <GroupedList name="myList" searchable="true" dataSource="ProcessContext::OverviewList.Items[]">
            <Items name="Items" itemPattern="myItemPattern">
              <ItemListLayout>
                <Default>
                  <Col width="10em">
                    <Row layoutType="ItemSecondary" bindingId="Button1" />
                  </Col>
                </Default>
              </ItemListLayout>
              <Bindings>   
                <Binding target="Button1" type="Button" binding=".displayedImageId" bindingMode="ONE_WAY" imageType=".svg" longPressMenuId="longPressMenu1"/>
                <Binding target="Button2" type="Button" binding=".displayedImageId2" bindingMode="ONE_WAY" imageType=".svg" longPressMenuId="longPressMenu2"/>
              </Bindings>
              <LongPressMenu name="longPressMenu1" dataSource="ProcessContext::someLo">
                <Items name="LongPressMenuItems">
                  <Bindings>
                    <Binding target="Icon" type="Image" binding=".actionImg" />
                    <Binding target="Text" type="Label" binding=".actionId" />
                    <Binding type="Editable" target="Editable" binding=".actionEnabled" />
                    <Binding type="Visible" target="Visible" binding=".actionVisible" />
                  </Bindings>
                </Items>
              </LongPressMenu>
              <LongPressMenu name="longPressMenu2" dataSource="ProcessContext::someLo">
                <Items name="LongPressMenuItems">
                  <Bindings>
                    <Binding target="Icon" type="Image" binding=".actionImg" />
                    <Binding target="Text" type="Label" binding=".actionId" />
                    <Binding type="Editable" target="Editable" binding=".actionEnabled" />
                    <Binding type="Visible" target="Visible" binding=".actionVisible" />
                  </Bindings>
                </Items>
              </LongPressMenu>
            </Items>
            <Events>
              <ListButtonPressedEvent event="buttonPressed">
                <Params>
                  <Param name="pKey" value=".pKey" />
                </Params>
              </ListButtonPressedEvent>
              <LongPressMenuOpeningEvent event="someEventHandler1">  
                <Params>
                  <Param name="pKey" value=".pKey" />
                </Params>
              </LongPressMenuOpeningEvent>
              <LongPressMenuSelectedEvent event="someEventHandler2">  
                <Params>
                  <Param name="pKey" value=".pKey" />
                </Params>
              </LongPressMenuSelectedEvent>
            </Events>
          </GroupedList>
           
          Loading
          Salesforce Help | Article