that’s tagged with $:/tags/KeyboardShortcut and has a key that’s cmd-0. I can see it being called if I add an action-log below the action-sendmessage, so I know that the key combo is being detected.
I can open $:/phajas/spaces/modal in a modal, but hitting cmd-0 will not close the modal. If I put the action-sendmessage in a button inside $:/phajas/spaces/modal, it works.
I must be doing something wrong. How can I close a modal with action-sendmessage from a keyboard shortcut?
Thanks saq. That gets me closer (by wrapping in a $keyboard widget), but still having trouble:
The modal doesn’t have focus, so I need to focus a field inside the modal before the shortcut works
The tm-focus-selector message doesn’t let me focus the modal after opening it - this may show my lack of understanding of JS and DOM focus support. I tried this:
Another alternative is to have an $edit-text widget in the modal (could even be hidden) that grabs focus on creation using the focus attribute of the widget.
The tabindex property is all lower case. Try this code again with this correction.
Also make sure that the $:/phajas/spaces/modal tiddler is not open in the story when you trigger the modal, otherwise the DIV in the story will get focus. You can avoid this issue by making your selector more specific, for example: .tc-modal .phajas-modal
Also, change the close action to: <$action-sendmessage $message="tm-close-tiddler"/>