Getting keypresses in window of Status Menu app

I’ve got a module which creates a MovableModal window with multiple choices for the user to select options. Because it’s created on the fly, to get keypresses (up, down, return, esc), I’m using:

AddHandler w.keydown, AddressOf KeyDown

This works fine in Desktop Apps, but when I call it from a Status Menu app, it doesn’t get keypresses.

What am I doing wrong, or can’t it be done? Thanks.

Are you removing the KeyDown handler when the window closes? You need to, every AddHandler requires a RemoveHander at some point.

Well, that sounds odd.

Are you creating the MovableModal window dynamically using New DesktopWindow, like in this thread: Making desktopwindow at runtime with controls inside?

The NSEventMonitorMBS class might be able to help you, but it depends on what you are trying to accomplish?

What is that ?

Ian, thanks for this. I wasn’t removing the handlers, but I added the removal and the issue remains.

Status menus are the items in the right side of the system menubar.

I’m creating the window with New DesktopWindow, then adding a canvas, label, and any number of buttons.

I’m trying to offer the user a way to chose buttons by keystroke or mouse. I use this module in several Desktop Apps. Thanks for the tip about NSEventMonitorMBS. I’ll look into that.

1 Like

BTW, I’m getting System Beeps when I press any key while in the Status Menu app. The other thing I’ve noticed is that when I set a breakpoint (anywhere in the app), keypresses don’t work in the Xojo IDE either.