Instruction set reference
HIPE_OP_SET_FOCUS
Gives keyboard focus to the specified element.
- location: The location to which to apply keyboard focus.
Notes
| Element | Caret or selection after SET_FOCUS |
| Text input, textarea, editable element focused before | As it was when the element last lost focus. |
| Text input, first focus | Caret at the end of its value, or as HIPE_OP_CARAT_POSITION set it. |
| Textarea or editable element, first focus | Caret at the start, or as HIPE_OP_CARAT_POSITION set it. |
| <iframe> | Focus goes to the element focused last inside the frame. |
- Nothing happens if the element can't take focus: hidden (display: none, visibility: hidden),
disabled, or not focusable (e.g. a div without tabindex, or location 0).
- It works while the window is inactive: the element has the focus once the window is activated.
- If the focused element is later hidden or disabled, it loses the focus (a blur event), and keys go to
the body.
Framed clients
| When a framed client sends SET_FOCUS | Result |
| The focus is inside its own frame | The element is focused at once. |
| The focus is elsewhere (the framing manager or another client) | Nothing changes yet: the element
is remembered, and gets the focus when the framing manager next focuses the client's <iframe>
(the latest request wins). |
| Its <iframe> is hidden (e.g. an inactive tab) | The same: remembered until the frame
is shown and focused. |
- If a framing manager hides the <iframe> that has the focus, the focus moves to the framing
manager's page; focusing the <iframe> again gives it back to the element that had it.
- A top-level client is never held back: it can focus any of its elements at any time.