Warn redefined key bindings

This commit is contained in:
Eduardo Bart 2012-07-23 01:44:15 -03:00
parent c9dce51458
commit dc8ef845ab
1 changed files with 6 additions and 0 deletions

View File

@ -100,6 +100,9 @@ function g_keyboard.bindKeyDown(keyComboDesc, callback, widget)
widget = widget or rootWidget
connectKeyDownEvent(widget)
local keyComboDesc = retranslateKeyComboDesc(keyComboDesc)
if widget.boundKeyDownCombos[keyComboDesc] then
pwarning('KeyDown event \'' .. keyComboDesc .. '\' redefined on widget ' .. widget:getId())
end
widget.boundKeyDownCombos[keyComboDesc] = callback
end
@ -108,6 +111,9 @@ function g_keyboard.bindKeyPress(keyComboDesc, callback, widget, autoRepeatDelay
widget = widget or rootWidget
connectKeyPressEvent(widget)
local keyComboDesc = retranslateKeyComboDesc(keyComboDesc)
if widget.boundKeyPressCombos[keyComboDesc] then
pwarning('KeyPress event \'' .. keyComboDesc .. '\' redefined on widget ' .. widget:getId())
end
widget.boundKeyPressCombos[keyComboDesc] = { callback = callback, autoRepeatDelay = autoRepeatDelay }
widget:setAutoRepeatDelay(math.min(autoRepeatDelay, widget:getAutoRepeatDelay()))
end