*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="utility.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS menulib AS container 
 	*< CLASSDATA: Baseclass="container" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<DefinedPropArrayMethod>
		*m: deactivatemenu
		*m: showmenu
	*</DefinedPropArrayMethod>

	*<PropValue>
		BackColor = 0,0,255
		Height = 15
		Name = "menulib"
		Visible = .F.
		Width = 50
	*</PropValue>
	
	PROCEDURE deactivatemenu
		DEACTIVATE MENU _popShortcutMenu
		
	ENDPROC

	PROCEDURE Destroy
		this.DeactivateMenu
		
	ENDPROC

	PROCEDURE showmenu
		LPARAMETERS taMenu,tcOnSelection
		LOCAL lcOnSelection,lnMenuCount,lnCount,llDoubleArray
		LOCAL lcMenuItem,lcMenuSelection
		EXTERNAL ARRAY taMenu
		
		IF PARAMETERS()=0 OR TYPE("taMenu")#"C"
			RETURN .F.
		ENDIF
		lnMenuCount=0
		lnMenuCount=ALEN(taMenu,1)
		IF lnMenuCount=0
			RETURN .F.
		ENDIF
		llDoubleArray=(ALEN(taMenu,2)>0)
		ACTIVATE SCREEN
		DEACTIVATE POPUP _popShortcutMenu
		DEFINE POPUP _popShortcutMenu ;
				FROM MROW(),MCOL() ;
				MARGIN ;
				RELATIVE ;
				SHORTCUT
		FOR lnCount = 1 TO lnMenuCount
			lcMenuItem=IIF(llDoubleArray,taMenu[lnCount,1],taMenu[lnCount])
			DEFINE BAR lnCount OF _popShortcutMenu PROMPT (lcMenuItem)
		ENDFOR
		ON SELECTION POPUP _popShortcutMenu DEACTIVATE POPUP _popShortcutMenu
		ACTIVATE POPUP _popShortcutMenu
		RELEASE POPUP _popShortcutMenu
		IF BAR()=0
			RETURN .F.
		ENDIF
		IF llDoubleArray
			 lcMenuSelection=taMenu[BAR(),2]
			 IF NOT EMPTY(lcMenuSelection) AND TYPE("lcMenuSelection")=="C"
			 	lcOnSelection=ALLTRIM(lcMenuSelection)
			 ENDIF
			 IF EMPTY(lcOnSelection)
				lcOnSelection=ALLTRIM(IIF(EMPTY(tcOnSelection),"",tcOnSelection))
			 ENDIF
		ELSE
			lcOnSelection=ALLTRIM(IIF(EMPTY(tcOnSelection),"",tcOnSelection))
		ENDIF
		IF EMPTY(lcOnSelection)
			RETURN .F.
		ENDIF
		&lcOnSelection
		
	ENDPROC

ENDDEFINE
