Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can a menu appear only upon rightclick?

    Hi,

    Is it possible for a menu to appear only when a user right clicks the listbox item?

    How can we enable right-click menus?

  • #2
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    With a list box you are going to have a bit harder of a time getting a right clicking menu to work. Mostly due to IE using windows controls (which the list box is) and that being on top of every thing. Basically what you would need to do is set the listbox's on click event to a function

    <select onclick='lbHandleClick(event);'></select>

    Then in that function you need to first find out if it is a right click (Search the forums for that, there are plenty of examples). If it is a right click then you need to create a div that looks like the list box, hide the actual listbox, and show the div, then pop the menu.

    Fun Fun! But definatly do able.
    Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,472
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Many browsers don't allow you to override the regular right click context menu.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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