Results 1 to 8 of 8

Thread: Make right-click equivalent to clicking left then right

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    774

    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.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    774

    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.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    774

    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.

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Make right-click equivalent to clicking left then right

    I've just enabled edit mode in the WebBrowser control.
    Oh well, that's different th...... wait! ... you did what?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    774

    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.

  8. #8
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width