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

Get help using Construct 2

Post » Mon Aug 04, 2014 6:58 am

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?
B
15
S
4
Posts: 138
Reputation: 2,003

Post » Mon Aug 04, 2014 10:19 pm

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.
Image
B
80
S
30
G
12
Posts: 517
Reputation: 12,713

Post » Mon Aug 04, 2014 11:33 pm

If you give the list an id and use the browser object you could prevent the context menu.
Code: Select all
some_id.oncontextmenu = function(e){e.preventDefault();}


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: Select all
some_id.oncontextmenu = function(e){e.preventDefault();c2_callFunction('onrightclick');}


Function on 'onrightclick'
Selected item text is "Item 1" Do something
B
11
S
2
G
1
Posts: 202
Reputation: 1,580


Return to How do I....?

Who is online

Users browsing this forum: wertt22 and 20 guests