I ran into some strange behavior when working with mouse events in a custom dialog and wanted to check if this is expected or a bug. I added a small example script below.
I noticed two issues that do not seem to be documented in the API and they are causing problems in my tool.
Here is the example code I used for testing.
local vb = renoise.ViewBuilder()
local dialog
function show_test_dialog()
if dialog and dialog.visible then
dialog:show()
return
end
local stack = vb:stack {
mouse_events = {
"enter","exit","move","down","up","double","drag","wheel"
},
mouse_handler = function(e)
print("----- " .. os.date("%Y-%m-%d %H:%M:%S"))
rprint(e)
return e
end,
vb:canvas {
id = "canvas",
width = 400,
height = 300,
mode = "transparent",
render = function(ctx)
ctx:clear()
end
},
vb:button {
id = "btn",
text = "Test Button",
width = 120,
height = 30,
origin = {
x = 180,
y = 120
}
},
}
local content = vb:column {
margin = 0,
spacing = 0,
stack
}
dialog = renoise.app():show_custom_dialog(
"Stack Mouse Events",
content
)
end
show_test_dialog()
Problem 1
When the mouse is hovering over the dialog and the dialog is in focus and press only the control key on macOS, then I get a mouse move event every time the control key is pressed or released even though nothing about the event data actually changes. The event contains no meaningful difference. Other modifiers also trigger mouse move but at least those show some changes in their modifier flags.
Is this intended behavior? If yes I think it would be helpful if these events would identify themselves as modifier only changes so they can be filtered out. Alternatively maybe modifier related events should only be generated when explicitly enabled through mouse_events.
Problem 2
Move the mouse away from the button hold the left mouse button down then hold control key. Move the mouse over the button release the left mouse button and then release the control key. When the control key is released the hover_views array no longer contains the button id even though the cursor is still on top of it.
The same issue happens with other modifier keys.
This makes it difficult to rely on hover_views because modifier keys break the expected behavior.