0 Favourites

How do I achieve right-click of selected item in a list box

  • I'm trying to get an even triggered when a particular item in a list is right-clicked, such as delete or another list of possible options to be displayed on rightclick on an item in my list box. but right click on the listbox as a whole always bring up this list of back, forward, reload, print etc. Anyway around this?

  • As far as i know any dom object takes control of mouse events when you're hovering over it, so c2 won't even react to any mouse input, even if you'll get around the menu.

    You'll have to make a costume plugin for that, or make the menu from scratch using text/sprites.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • If you give the list an id and use the browser object you could prevent the context menu.

    some_id.oncontextmenu = function(e){e.preventDefault();}[/code:nmimjs26]
    Then you'll run into the other problem mentioned of clicks not registering. 
    To solve this, add the function object to your project, create a function called onrightclick and use c2_callFunction  to fire a callback.
    Now your code would look like this instead
    On start of layout execute JS  [code:nmimjs26]some_id.oncontextmenu = function(e){e.preventDefault();c2_callFunction('onrightclick');}[/code:nmimjs26]
    Function on 'onrightclick'
    Selected item text is "Item 1"       Do something
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread sticky
203 458,265
Kyatric's avatar
Kyatric Construct Team Support
Unread hot topic
173 28,549
Rich's avatar
Unread hot topic
0 Favourites
My ongoing list
133 6,080
thomasmahler's avatar