Make right-click equivalent to clicking left then right
I am working on a WYSIWYG HTML editor using a Webbrowser control. I'm working on ways to edit objects/elements (images in particular) after they have been added to the control. I want a right-click to bring up properties - spacing, border width, border colour etc) which can be modified. I have added a mousedown event to the webbrowser control. The problem is that right-clicking (say) an image, does not select the image, as left-clicking would do, so it's hard to work out which object has been clicked. If I left-click first (to select the image), then right-click, I can work out the rest.
Is there an easy way to make a right-click behave as if the user had left-clicked, then right-clicked?
Thanks.
Re: Make right-click equivalent to clicking left then right
Well firstly it must be possible to use just the right-click cos Chrome's Inspect Element works in exactly that way but secondly and more importantly, if every right click is preceded with a left click what are you going to do about links and interactive elements. If they are triggered, won't that mess up your whole scheme?
Can you not use the click to gather co-ordinates for use with GetElementFromPoint?
Re: Make right-click equivalent to clicking left then right
I don't think it would mess anything up. This is an editor, not a browser. Left clicking on an element highlights it; right-clicking does not. I'm sure there are multiple ways to get the functionality I would like, but at the moment a left-click then right-click is doing what I want. I would just like to combine those two effects into one.
Re: Make right-click equivalent to clicking left then right
Then I'm a tad confused. If you're using a WebBrowser control a left click does what a left click should do unless you've overridden that in some way. If you've achieved a left click that selects rather than activates a link, why can you not simply do exactly the same for a right click with the added functionality subsequently?
Re: Make right-click equivalent to clicking left then right
I've just enabled edit mode in the WebBrowser control. Selecting an object when it's left-clicked is built-in functionality.
Perhaps I should have asked a different question, as the idea of creating a left-click when an object is right-clicked would be a bit of a cludge. I'll have a play for a while and if I still can't solve the problem I will create a new thread.
Re: Make right-click equivalent to clicking left then right
Quote:
I've just enabled edit mode in the WebBrowser control.
Oh well, that's different th...... wait! ... you did what?
Re: Make right-click equivalent to clicking left then right
These snippets will give you the gist of it:
Code:
Imports mshtml
Dim Mdoc As IHTMLDocument2
Mdoc = webbrowser1.Document.DomDocument
Mdoc.designMode = "On"
Great fun to be had! Hard work to get all the required functionality though.
BTW, I re-visited GetElementFromPoint and have it doing what I want, so no need now for crude left-clicks + right-clicks.
Re: Make right-click equivalent to clicking left then right
Will ya look at that! I thought designMode had gone to the Great Coder in the sky!