Page 1 of 1

Disable right click menu in the webgadget

Posted: Mon Dec 17, 2012 8:15 pm
by utopiomania
This seems to be the only way to disable the webgadget context menu if you have installed Google Chrome:

Code: Select all

  html + "<script language = 'vbscript'>" + #CR$
  
  html + "sub document_onContextmenu()" + #CR$
  html + "  Window.event.returnValue = false" + #CR$
  html + "end sub" + #CR$

  html + "</script>" + #CR$
The old one:

Code: Select all

html + "<body oncontextmenu = 'return false;'>" + #CR$
doesn't work any more :( code goes in the head section.

Edit: I use the webgadget as the main UI for my apps, so disabling the context menu, or creating them myself is
a necessity :)

Re: Disable right click menu in the webgadget

Posted: Tue Dec 18, 2012 6:37 am
by kvitaliy
And this code does not work?

Code: Select all

 SetGadgetAttribute(#Web_0,#PB_Web_BlockPopupMenu,1)

Re: Disable right click menu in the webgadget

Posted: Tue Dec 18, 2012 7:52 pm
by utopiomania

Code: Select all

SetGadgetAttribute(#Web_0,#PB_Web_BlockPopupMenu,1)
Can I use this to create my own right click menu? And forgot to mention that I also write hta's.

Re: Disable right click menu in the webgadget

Posted: Wed Dec 19, 2012 5:47 am
by kvitaliy
utopiomania wrote:

Code: Select all

SetGadgetAttribute(#Web_0,#PB_Web_BlockPopupMenu,1)
Can I use this to create my own right click menu?
Yes, of course

Code: Select all

OpenWindow(0, 632, 42, 400, 400, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    WebGadget(0, 30, 40, 350, 250, "http://www.purebasic.com")
    SetGadgetAttribute(0,#PB_Web_BlockPopupMenu,1)
    If CreatePopupMenu(0)      
      MenuItem(1, "Open")      
      MenuItem(2, "Save")      
     EndIf
Repeat
  Event = WaitWindowEvent()
  Select Event
    Case #PB_Event_Menu       
          Select EventMenu()     
            Case 1 : Debug "Menu: Open"
            Case 2 : Debug "Menu: Save"
          EndSelect   
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType = EventType()
      If EventGadget = 0
        If EventType = 7
          DisplayPopupMenu(0, WindowID(0))  
        EndIf 
      EndIf
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      If EventWindow = 0
        CloseWindow(0)
        Break
      EndIf
  EndSelect
ForEver

Re: Disable right click menu in the webgadget

Posted: Wed Dec 19, 2012 9:42 pm
by utopiomania
:) Like! Cool, didn't know that! Many Thanks!

Re: Disable right click menu in the webgadget

Posted: Thu Dec 20, 2012 10:37 pm
by utopiomania
Probably need to script the popup menu though, since it needs to change With the items in the UI ;-)

Re: Disable right click menu in the webgadget

Posted: Thu Dec 20, 2012 11:04 pm
by citystate
you could always pre-create different popup lists and just display the one you need using the menu number