2020-03-31

ShortCuts made easy

This is a very old tip, but might be helpful for someone :-)
Instead of adding some big scripts manually, or creating specific classes, or even using the VFP native menu designer.

Just add a method to your form, call it "SHORTCUTMENU"


LPARAMETERS tcPar1, tcPar2, tcPar3, tcPar4, tcPar5, tcPar6

LOCAL lnCount, n, lcPrompt, lcPicture, lnOption
m.lnCount  = PCOUNT()
m.lnOption = 0
DEFINE POPUP myShortCut SHORTCUT RELATIVE FROM MROW(), MCOL()

FOR m.n = 1 TO m.lnCount
    m.lcPrompt = EVALUATE("tcPar" + TRANSFORM(m.n))
    m.lcPicture = GETWORDNUM(m.lcPrompt, 2, ";")
    m.lcPrompt = GETWORDNUM(m.lcPrompt, 1, ";")
    DEFINE BAR m.n OF myShortCut PROMPT m.lcPrompt PICTURE m.lcPicture
ENDFOR

ON SELECTION POPUP myShortCut m.lnOption = BAR()
ACTIVATE POPUP myShortCut
RETURN m.lnOption