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

0 favourites
  • 3 posts
From the Asset Store
Template for scrollable list, fully documented in comment and video
  • 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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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)