Disable right click menu in the webgadget

Share your advanced PureBasic knowledge/code with the community.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Disable right click menu in the webgadget

Post 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 :)
kvitaliy
Enthusiast
Enthusiast
Posts: 162
Joined: Mon May 10, 2010 4:02 pm

Re: Disable right click menu in the webgadget

Post by kvitaliy »

And this code does not work?

Code: Select all

 SetGadgetAttribute(#Web_0,#PB_Web_BlockPopupMenu,1)
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Re: Disable right click menu in the webgadget

Post 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.
kvitaliy
Enthusiast
Enthusiast
Posts: 162
Joined: Mon May 10, 2010 4:02 pm

Re: Disable right click menu in the webgadget

Post 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
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Re: Disable right click menu in the webgadget

Post by utopiomania »

:) Like! Cool, didn't know that! Many Thanks!
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Re: Disable right click menu in the webgadget

Post by utopiomania »

Probably need to script the popup menu though, since it needs to change With the items in the UI ;-)
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: Disable right click menu in the webgadget

Post by citystate »

you could always pre-create different popup lists and just display the one you need using the menu number
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
Post Reply