Web Button contextual menu

I have decided to stop trying to develop a menu for now until we get another release cleaning it up. For now Id like to use a button with contextual menu. Is there a way to display a contextual menu just on button press (not a right click) ? Any examples of code would be great. Thanks.

There’s nothing built in but it can be done with Javascript. Here’s two helper methods to do what you want. This also allows you to lazily create contextual menu’s as well as use them on mobile. Currently mobile has no way of presenting a contextual menu which is a pretty glaring oversight if you ask me.

Public Sub TriggerContextualMenu(extends control as WebUIControl)
  var js as string = "jQuery('#"+control.ControlID+"').trigger('contextmenu')"
End Sub

Public Sub ExecuteJavaScriptWithDelay(extends wc as WebControl, script as string, milliseconds as integer)
  //Often can be used to overcome temporary Xojo bugs, ensure there is a feedback case if you use it in this way so you can come back and convert it to a normal ExecuteJavascript Eventually
  dim js() as string
  dim name as string = wc.ControlID+"_"+str(ticks)
  js.AddRow("function "+name+"() {try{")
  js.AddRow("setTimeout("+name+", "+str(milliseconds).ReplaceAll(",","")+");")
  dim jsScript as string = join(js, EndOfLine)
End Sub
1 Like