LocalOnButtonPressed is not fired when cursor is enabled in widget

For example if you have a button handle

function MyScript:LocalOnButtonPressed(btn)
  if btn == "forward" 
    self:GetEntity().myWidget:CallFunction("SelectNext")
  end
end

This method would never be called.

In my opinion, the controls should continue to fire callbacks in creator code.

Our use case for this is this:

We have a menu that is controlled by the controller. We would like keyboard/mouse players to be able to use the mouse with the menu because it is more natural for them to do so. Right now, we can only do one or the other.

So it’s either inconvenient for the keyboard/mouse player, or the controller player.

Version: 0.6.219.105635

I believe this is by design, the expectation is now to do this in the Widget JS code e.g.

   		engine.on("LocalOnButtonPressed", function(button) {
   		if (button == "forward") {
      		Crayta.callLua("LocalOnButtonPressed",button)
      		}
   		})

Then in LUA call a function:

function UserDebugMenuScript:LocalOnButtonPressed(button)
	if button == "forward" then
		-- Do code here
	end
end

If this still isn’t working for you then I can see about raising an issue along with an example.

1 Like

That’s fascinating. I didn’t know we could listen to events like that with engine. I’ll try that out after work and get back to you.

Yeah, I had a similar issue and this is what the game engine team suggested as I think the “cursor is enabled” is a new feature. If it’s not working out for you then I can go back to them. It certainly works for my case.

This worked great