PDA

View Full Version : window:addListener - stopping my applet working



iisfaq
2009-09-14, 17:59
If I add this code to a function in LUA that creates a window object the function appears to fail and no longer does anything.

window:addListener(EVENT_KEY_PRESS | EVENT_MOUSE_PRESS,
function(event)
window:hide()
return EVENT_CONSUME
end
)

Is there anything specific I should be including to get this to work?

Where are EVENT_KEY_PRESS and EVENT_CONSUME defined?

I found this in one of the error logs

attempt to perform bitwise operation on global 'EVENT_KEY_PRESS' (a nil value)


Any help appreciated

Chris

iisfaq
2009-09-14, 18:18
I found a solution but I do not understand why not all applets do not need this.

local EVENT_KEY_PRESS = jive.ui.EVENT_KEY_PRESS
local EVENT_MOUSE_PRESS = jive.ui.EVENT_MOUSE_PRESS



Chris

erland
2009-09-15, 09:43
I found a solution but I do not understand why not all applets do not need this.

Don't they have to do this if they use these constants ?

Fred
2009-09-15, 12:09
If they use the constants, they need these lines. Otherwise Lua interprets the value as NULL, and nothing happens as observed by the OP.

There is a lua file (in etc/strict.lua in the Lua distrib and/or Jive svn) that you can require and that will make the program fail if using an undeclared variable. Useful when debugging strange issues.

HTH
Fred