Unexpected mouse move events when pressing modifier keys, missing id's in `hover_views`

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.

1) was added on purpose, I think @Raul needed this for his tool to change the mouse cursor when not moving the mouse but only pressing modifiers while hovering a view.

Need to carefully check 2) Seems indeed like a bug that needs the be fixed.

Yeah, for #1 that’s what I expected. Right now I’m handling it via “appidle” and a global variable that keeps track of the modifier key states. The reason I’m doing it this way is that the piano roll isn’t always in focus, and I’m using buttons to show which tool (move, draw, …) is active. It would be pretty confusing if that didn’t update. The modifier event in the mouse handler only works when the tool window has focus.

Regarding problem #2, what’s happening in my tool at the moment is that the mouse cursor ends up with the wrong icon. This occurs when you create a selection rectangle with Ctrl and then release everything while the cursor is over a note.

I’ll see if I can find a workaround and just filter out those modifier events. Do modifier change events get triggered for all mouse events, or only for move? It might be worth clarifying this in the API documentation. If it’s tied to move, it could make sense for future API versions to have a move event without modifier tracking (“moveonly”).

Edit: It looks like in problem #2 the move event that gets triggered when releasing one of the modifier keys is using incorrect coordinates. So its currently not possible for me to filter it out :confused: