v0.7.0
Full Changelog: v0.6.0...v0.7.0
Deprecated
- Deprecate
item
in favor oflabel
for menu item labels- This is just a clearer name for the property.
- Deprecate
shortcut
in favor ofshortcutLabel
andariaKeyShortcuts
aria-keyshortcuts
needs "Control" spelled out, and for macOS "Meta" for the command key, unlike the traditional visual representations. Hence the separation of concerns.
Added
AccessKeys
API for parsing and rendering labels with access keys (syntax:&
defines the following character as the access key,&&
inserts one literal ampersand)AccessKeys.escape(label)
escapes ampersands by doubling themAccessKeys.unescape(label)
unescapes ampersands by removing one of each pairAccessKeys.has(label)
returns whether the label has an access keyAccessKeys.get(label)
returns the access key character, ornull
if there isn't oneAccessKeys.remove(label)
returns plain text without access key indicator, likeAccessKeys.toText()
but with a special case to remove parentheticals such as " (&N)" rather than just the ampersandAccessKeys.toText(label)
returns plain text without access key syntaxAccessKeys.toHTML(label)
returns HTML with<span class="menu-hotkey">
around the access key (usesAccessKeys.toFragment
for security)AccessKeys.toFragment(label)
returns aDocumentFragment
with<span class="menu-hotkey">
wrapping the access key character- private
AccessKeys.indexOf(label)
(don't use this) - (In the future, the CSS class "menu-hotkey" may be renamed to "access-key", perhaps with a prefix.)
- Radio menu item support
- TypeScript types for the whole library
- Type declarations are included as part of the
os-gui
package, inos-gui.d.ts
- You may need to reference the declarations file explicitly in your
tsconfig.json
'sinclude
orfiles
array, or use a/// <reference path="node_modules/os-gui/os-gui.d.ts" />
directive. I'm not sure how exactly this is supposed to work.
- Type declarations are included as part of the
$Window
methods:- experimental
onFocus
,onBlur
, andonClosed
API for events (looking to remove dependency on jQuery) - private
addChildWindow($window)
(don't use this) - private
unminimize()
(don't use this)
- experimental
$Window
properties:closed
: Whether the window has been closed.icons
: The icons of the window at different sizes, as set byoptions.icons
orsetIcons()
.$minimize
: the minimize button$maximize
: the maximize button- private
$title_area
(don't use this) - private
$icon
(don't use this)
$Window
propertyelement
(already mentioned but now has a section like other properties)- Menu item specification properties:
shortcutLabel
for defining the label of the shortcut key combination separately from theariaKeyShortcuts
property; this replaces the oldshortcut
propertyariaKeyShortcuts
for defining the access key combination for the menu item. Must follow aria-keyshortcuts syntax.label
for defining the label of the menu item; this replaces the olditem
propertyvalue
(only for radio items) for defining a radio option value
- Docs for positioning windows
Changed
- Handle synthetic events, including when pointerId is not given
- This is for jspaint, which triggers pointerup when pressing both mouse buttons to cancel a drawing gesture, and on blur.
- Make menu bars wrap to multiple rows when needed
- Close menus if focus leaves menu popups and menu bar
- If you click on the empty space on the menu bar, it should close menus, not just unhighlight.
- This also seems to fix the case where a window is closed while menus are open (you can test this with the Trigger Station in test.html)
- Improve menu bar code and some behavior
- Prevent some unnecessary DOM updates with highlighting and opening/closing.
- Check for specific menu bar instance when testing focus
- Make menu bar only ever close its own menu popups
- Reduce redundancy in menu closing code
- Fix cycling behavior with Up key: pressing up in a menu opened by clicking (such that the first item isn't automatically highlighted) now goes to the bottom item, instead of the top item (or the second-to-bottom item if you had hovered a menu item within and then moved the mouse out). It still focuses the top item if you open the menu via up/down arrow as this matches the Windows 98 behavior for using the keyboard.
- This commit might actually break closing menu popups in the case that the menu bar is removed from the DOM, because it relies on sending events...
- (I'm not sure if I followed up on this.)
- Use event.key instead of event.keyCode
- Prevent entering disabled submenus [with the keyboard?]
- Don't dispatch update events when hovering menu items
- This only affects the Schrödinger's Checkbox as far as I know, and arguably makes it more thematic, since it only changes when "observing" it.
- (Should it be called Schrödinger's Tick, btw? haha, gross.)
- Make menu popups inherit the theme from the menu bar
- Patch drag handling for Eye Gaze Mode in JS Paint
- Fix menu button border offset on press, and oscillating menu opening when hovering between two menu buttons
- Fix: keep menu button highlighted if clicked to close
- Highlight/open menus when moving mouse at all while over menu button
- Fix: don't trigger menu items if holding Ctrl
- For example, in Paint, with the Help menu open, Ctrl+A shouldn't open About Paint, it should Select All, using the app-global keyboard shortcut.
- SVG icons for checkbox/radio/submenu icons are now defined in CSS using
mask-image
- Fix subpixel issues with menu button borders, and margin-bottom (and greatly simplify, by adding a wrapper span)
- Refocus last focused control outside menus on close to support copy/paste
- This generalizes refocusing the last focused control within the window to also work for controls outside the window, I think?
- Fix setting window title to empty string
- Previously, it returned the current window title instead of clearing it, due to incorrect handling of falsy values when differentiating between getter/setter method signatures.
MenuBar
menu item propertydescription
is now optional.
Fixed
see Changed