In the following code, “aPopupMenu.PopUp” fails to compile and presents the message:
“There is more than one item with this name and it’s not clear to which this refers.” and highlights “aPopupMenu.Popup”
Any clues as to why?
==============
[code]Public Sub handleRightClick()
// Construct and popup the contextual menu.
// Called by mouseDown for right button click.
dim ok as Boolean
dim aPopupMenu as MenuItem
aPopupMenu = New MenuItem // Create a new menu item
call onConstructContextualMenu( aPopupMenu, 0, 0 )
// Pass in popupMenu to be built.
aPopupMenu.PopUp
// FAILS TO COMPILE. Compiler says:
// “There is more than one item with this name and it’s
// not clear to which this refers.”
// and highlights “aPopupMenu.Popup”
ok = onContextualMenuAction( aPopupMenu )
// Handle selected entry of popupMenu
if not ok then
Alert CurrentMethodName, “Failed to handle right click for contextual menu.”
end
End Sub
Public Function onConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) as Boolean
// Construct the contextual menu that is presented upon right-click or
// control left-click.
base.Append( New MenuItem( “Cut” ) )
base.Append( New MenuItem( MenuItem.TextSeparator ) )
base.Append( New MenuItem( “Clear” ) )
return true // Don’t pass the event up.
End Function
Public Function onContextualMenuAction(hitItem as MenuItem) as Boolean
// Handle selection of hitItem from the presented contextual menu.
Dim txt as String = hitItem.Text
if txt = “Cut” then
onCutPressed
elseif txt = “Clear” then
onClearAction
else
Alert CurrentMethodName, "Dont’ know how to handle contextual item " + txt.quote
end
return true // Don’t pass the event up.
End Function
[/code]