Mouse Right Click ?

Has anybody got a way to detect right clicking on objects ?

Corona supports a “mouse” event.  Have a look at the documentation here…

   https://docs.coronalabs.com/daily/api/event/mouse/index.html

The event’s “isSecondaryButtonDown” property let’s you know if the right mouse button is currently being held down.  Note this is called a “secondary” button because the OS has an option to let the end-user choose which mouse button should be considered the primary button (typically the left button) and the secondary buttons (typically the right button).

   https://docs.coronalabs.com/daily/api/event/mouse/isSecondaryButtonDown.html

Thanks, but that tells me the user clicked the mouse “somewhere”, though it does give me an X and Y

Is there a way to find out which object the mouse was over at the time other than writing code to iterate though all the objects to find it ?

You can a “mouse” event listener to a display object too.  Just like how you can do it with “touch” and “tap” events.  That way, you’ll only get mouse state changes while the cursor is over an object.

-- Create a display object. local myDisplayObject = display.newRect ( display.contentCenterX, display.contentCenterY, display.contentWidth \* 0.5, display.contentHeight \* 0.5 ) -- Create a new property on that object to store the last right click state. -- You need this in order to recognize when the button state changes. myDisplayObject.wasSecondaryMouseButtonDown = false -- Add a "mouse" event handling function to the display object. myDisplayObject.mouse = function(event) local wasHandled = false -- Determine if the right mouse button was just released. -- ie: If it has transitioned from a down state to an up state. -- Note that apps normally display popup menus when the button is released. if (self.wasSecondaryMouseButtonDown and event.isSecondaryButtonDown) then -- The right mouse button has just been released. -- If you return true, then the mouse event will not be dispatched to -- display objects below the mouse cursor. wasHandled = true end -- Store the current right button state for the next mouse event call. self.wasSecondaryMouseButtonDown = event.isSecondaryButtonDown return wasHandled end -- Set up the display object to listen for mouse events. myDisplayObject:addEventListener("mouse", myDisplayObject)

Thats great. Just realised however that there seems to be no events for the scroll wheel effect.

That really suppers it for my app as need to use thumb wheel type interaction to scroll up and down through table views. User having to click and drag to scroll is not very “desktop”

Is there any plans to put this in or a workaround ?

We don’t have any “official” support for the mouse scroll wheel yet.

We definitely want to add it in the future, but it’s not scheduled in yet.

Corona supports a “mouse” event.  Have a look at the documentation here…

   https://docs.coronalabs.com/daily/api/event/mouse/index.html

The event’s “isSecondaryButtonDown” property let’s you know if the right mouse button is currently being held down.  Note this is called a “secondary” button because the OS has an option to let the end-user choose which mouse button should be considered the primary button (typically the left button) and the secondary buttons (typically the right button).

   https://docs.coronalabs.com/daily/api/event/mouse/isSecondaryButtonDown.html

Thanks, but that tells me the user clicked the mouse “somewhere”, though it does give me an X and Y

Is there a way to find out which object the mouse was over at the time other than writing code to iterate though all the objects to find it ?

You can a “mouse” event listener to a display object too.  Just like how you can do it with “touch” and “tap” events.  That way, you’ll only get mouse state changes while the cursor is over an object.

-- Create a display object. local myDisplayObject = display.newRect ( display.contentCenterX, display.contentCenterY, display.contentWidth \* 0.5, display.contentHeight \* 0.5 ) -- Create a new property on that object to store the last right click state. -- You need this in order to recognize when the button state changes. myDisplayObject.wasSecondaryMouseButtonDown = false -- Add a "mouse" event handling function to the display object. myDisplayObject.mouse = function(event) local wasHandled = false -- Determine if the right mouse button was just released. -- ie: If it has transitioned from a down state to an up state. -- Note that apps normally display popup menus when the button is released. if (self.wasSecondaryMouseButtonDown and event.isSecondaryButtonDown) then -- The right mouse button has just been released. -- If you return true, then the mouse event will not be dispatched to -- display objects below the mouse cursor. wasHandled = true end -- Store the current right button state for the next mouse event call. self.wasSecondaryMouseButtonDown = event.isSecondaryButtonDown return wasHandled end -- Set up the display object to listen for mouse events. myDisplayObject:addEventListener("mouse", myDisplayObject)

Thats great. Just realised however that there seems to be no events for the scroll wheel effect.

That really suppers it for my app as need to use thumb wheel type interaction to scroll up and down through table views. User having to click and drag to scroll is not very “desktop”

Is there any plans to put this in or a workaround ?

We don’t have any “official” support for the mouse scroll wheel yet.

We definitely want to add it in the future, but it’s not scheduled in yet.