Are there any examples of programmatically populating a ContextMenu which is in a table. The "Actioning a Table Row" example is close to what I'm looking for but that has the ContectMenu hardcoded in the DDS. Also EXAM0067 is close in terms of populating programmatically but it's not a ContextMenu. So something between those is what I'm looking for. If someone has an example similar to that, it would be nice to see that code. Thanks
jim
(RPG) Programatically populating a ContextMenu
-
JimKeating
- Posts: 12
- Joined: Thu Apr 19, 2012 11:45 pm
-
MarkDuignan
- Posts: 346
- Joined: Wed Apr 18, 2012 10:33 am
Re: (RPG) Programatically populating a ContextMenu
The simplest shipped example is in the demo source file LRNG_DEMO/SOURCEDEMO as member DEMOSTDPM.
DEMOSTDPM is a generic subroutine called by FormView programs using the name DemoStdPhonemenu(); - in effect other programs call DEMOSTDPM asking it to dynamically create a context menu named “STDPHONEMENU” for them.
The code following is DEMOSTDPM - main things to notice are:
• It creates a context menu named “STDPHONEMENU” that contains items “Make Phone Call” and “Send Message”.
• It loads up the menu entries dynamically from two compile time arrays named ItemText and ItemAction – but reading a data base table instead would be an easy change.
• Context menus get created into the /System.Menus namespace – so a menu named XXXXXXX (say) is available to all Form Views.
• The properties of /System.Menus.STDPHONEMENU are the Item, which itself has properties Text and the OnClick . It’s quite similar to a drop down.
• Once you create a context menu it remains alive for the duration of the client session – so you only need this do this once – which is why DEMOSTDPM has the “MenuItemDone” flag and does nto set on LR – in effect DEMOSTDPM will only build the menu once – not matter how many times the caller requests that it build the menu.
This is DEMOSTDPM ............
You can also find DEMOSTDLM that dynamically builds a location/GPS context menu named “STDLOCATIONMENU” and DEMOSTDMM that dynamically builds an e-mail related menu named “STDMAILMENU”.
DEMOSTDPM is a generic subroutine called by FormView programs using the name DemoStdPhonemenu(); - in effect other programs call DEMOSTDPM asking it to dynamically create a context menu named “STDPHONEMENU” for them.
The code following is DEMOSTDPM - main things to notice are:
• It creates a context menu named “STDPHONEMENU” that contains items “Make Phone Call” and “Send Message”.
• It loads up the menu entries dynamically from two compile time arrays named ItemText and ItemAction – but reading a data base table instead would be an easy change.
• Context menus get created into the /System.Menus namespace – so a menu named XXXXXXX (say) is available to all Form Views.
• The properties of /System.Menus.STDPHONEMENU are the Item, which itself has properties Text and the OnClick . It’s quite similar to a drop down.
• Once you create a context menu it remains alive for the duration of the client session – so you only need this do this once – which is why DEMOSTDPM has the “MenuItemDone” flag and does nto set on LR – in effect DEMOSTDPM will only build the menu once – not matter how many times the caller requests that it build the menu.
This is DEMOSTDPM ............
Code: Select all
H BNDDIR('LRNGSRV') DFTACTGRP(*no) ACTGRP(*caller)
H* ------------------------------------------------------------------------
H* This program is used to demonstrate a LRNG(Mobile Application) feature.
H* The source code is supplied for use as the customer sees fit.
H* No warranty is expressed or implied for this demonstration program.
F* -----------------------------------------------------------------------
F* Data structures, variables and prototypes
F* -----------------------------------------------------------------------
D* Standard include to bring in the external LRNG support function protypes
D/INCLUDE LRNGSOURCE,LRNGCOMMON
D* Standard include to bring in the demonstration definitions
D/INCLUDE SOURCEDEMO,DEMOCOMMON
D* Working fields
D DS
D MenuName C 'STDPHONEMENU'
D MenuItemCount C 2
D MenuItemDone 1A Inz('N')
D ItemText 20A Dim(2) CTDATA
D ItemAction 10A Dim(2) CTDATA
D ElementProp 256A Varying
D ItemProp 256A Varying
D Index 10I00
* -----------------------------------------------------------------------
* Standard entry parameter list for panel handling programs
* -----------------------------------------------------------------------
C *ENTRY PLIST
C PARM SystemINFO
C* -----------------------------------------------------------------------
C* Program logic
C* -----------------------------------------------------------------------
/free
- Ignore request if menu has already been built
if (MenuItemDone <> 'Y');
LRNG_UsingEx(*OFF : '/System.Menus' : MenuName);
For Index = 1 to MenuItemCount;
• Start using /System.Menus.STDPHONEMENU.Item%2 (say)
LRNG_Using('Item' : Idx(Index));
• Set /System.Menus.STDPHONEMENU.Item%2.Text
LRNG_AssignStrToProp(%trim(ItemText(Index)) : 'Text' );
• Set /System.Menus.STDPHONEMENU.Item%2.OnClick
LRNG_AssignStrToProp(
%trim(MenuName) + '_' + %trim(ItemAction(Index))
: 'OnClick');
LRNG_EndUsing();
EndFor;
MenuItemDone = 'Y';
LRNG_EndUsing();
Endif;
// Stay active
*InLR = *Off;
return;
/end-free
**
Make Phone Call
Send Message
**
PHONECALL
SENDSMSYou can also find DEMOSTDLM that dynamically builds a location/GPS context menu named “STDLOCATIONMENU” and DEMOSTDMM that dynamically builds an e-mail related menu named “STDMAILMENU”.