PDA

View Full Version : Web Object Right Click Management


Roboblue
12-09-2006, 11:40 AM
We have had several discussions on disabling the right click (RC) on a Web Object. I have coded a couple of examples and some others have, also. None that I have seen or coded have satisfied me.
I was wanting to make an small e book viewer and since IE supports so many formats (.html, .txt, .jpg, .gif, .rtf, wave, .mid, and others if the system has the plugins), I thought I would use the Web object to display the books. The same principal applies for a product catalog, picture viewer, media player, etc. So disabling RC became a priority.
I still haven't came up with an elegant way to totally disable RC.
However, I thought, why not just replace the IE RC menu with my own custom menu? So, I did.
Here are two examples that I came up with.
The first one is just an RC disabler.
The second one is a custom menu example.
In the second one, I used WORM's powerful (and free:yes ) keystroke dll to provide an external page Search function. It also has the page loading animation effect (on the Refresh button) I recently did.
To see the code, look at the Page-On Mouse Button event.
T0 prevent the RC menu from popping up outside of the Web object, you need to set the e_X and e_Y co-ordinates (or the inside coordinates of the object). This is the way I did it.

to get e_X co-ordinates
Web object from Left position and Web Object width
e_X > (left) and e_X < (Left + Width)

to get e_Y co-ordinates
Web object from Top position and Web Object Height
e_Y > (Top) and e_Y < (Top + Height)

This function, RCPos(), is in Global. Just be sure to change the object name (in this case "web") to the object you want to get the inside co-ordinates to. This would be useful for a Tab browser and to use same the code project to project.
I am also going to work on disabling the copy to clipboard keystrokes so that there isn't a way to select and copy. With that disabled, you can select with the left mouse, but not copy with Ctrl+C. Anyone wanting to do this right now is welcome to post it. I will, when it's done.
I haven't tried this yet, but I bet the same code would work for other objects as well, (like the WMP).

4thstar
05-10-2007, 02:57 PM
Hello Guys , almost exactly what i was after , it works great :)

question though..

I know this disables the right mouse button but i noticed that i can press the menu button on the keyboard and it displays the usual menu , not sure of the propper name for this button (very bottom 3 right from space bar with the Ctrl button to its right)

can anyone please advise to...

A: how i find the key number for that button
B: or what the number is..

Kind Regards
Carl

mz241508
05-10-2007, 03:15 PM
A: how i find the key number for that button
You can find the key numbers in the help file (Search for: Virtual Keyboard Codes decimal hex) or check this: Key Codes (http://mz.phpnet.us/key%20codes.htm)

RizlaUK
05-10-2007, 04:17 PM
also in the scripts folder in Gallery there is a "VirtualKeyCodes.lua", include this file in your global function to use the Decimal value of a key (rather than"VK.KEY")

Desolator
05-10-2007, 04:25 PM
Actually, that file makes it easier to use keystrokes, since you don't need to remember the codes, but simply use VK.KEY (i.e. VK.Delete).

ZUPOT
09-30-2007, 07:16 PM
Hi, as it is that I create a menu rigth clic with to say: Seleccionar (Select); Copiar (Copy); Colar (past); actualizar (Refresh)?
in web object

sorry my english, but I am Portuguese
thanks

thetford
11-24-2007, 01:55 PM
Thanks ROBO! just what I needed for my App!!!:yes

FoxLeader
12-21-2007, 12:03 AM
Thanks, that's exactly what I needed for my upcoming CoverFlow exemple!

Thanks Roboblue!

Regards,
FoxLeader

FoxLeader
12-24-2007, 02:01 PM
Ok... finally, I had some time to look at it and realized that it is simply displaying another menu. Since that exemple has been posted, has anybody succeed to completely disable the rightclick over the webobject?

Or I have an idea... load a Javascript in the current page which will block the right click. I'll see with this and I'll comeback!

FoxLeader
12-24-2007, 02:56 PM
If you have control on your page's content, you can use
<script language="javascript">
document.oncontextmenu = function() {
return false;
}
-->
</script>

Personally, that solved my needs.