1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00
Commit graph

238 commits

Author SHA1 Message Date
reuk
83e5264c86
Formatting: Remove double-dots from comments and other strings 2025-11-18 15:47:42 +00:00
Anthony Nicholls
60c34d3ccb PopupMenu: Adjust the bounds of a menu that intersects with safe inset areas 2025-10-10 18:07:52 +01:00
reuk
fdaf71b50f
PopupMenu: Fix some issues with positioning of initially-visible items
The old implementation had a few problems:

- For a target area near but not touching the bottom of the parent area,
  and a long menu with an initially-visible item halfway through the
  list, the initially-visible item would sometimes be obscured by the
  scroller area. The new implementation adjusts the size of the menu to
  ensure that there's enough additional room for the scroller areas.
- For a target area at the very top or very bottom of the target area,
  the menu would be positioned inconsistently; sometimes it would
  overlap with the target area, but other times it would be positioned
  with a gap separating the menu and target area. In the new
  implementation, if there's not enough room for scrollers to be
  positioned above/below the target area, the menu will always be
  positioned so that it touches but does not overlap the target area.
- The initially-selected item would normally be
  positioned as close as possible to the target area, but this wasn't
  always applied consistently for long menus, and the menu would
  sometimes only be scrolled enough to make the item visible at the end
  of the menu furthest from the target area. In the new implementation,
  the initially-visible item will always be positioned on top of the
  target area, or adjacent to it, depending on the available space.
2025-09-01 23:33:43 +01:00
reuk
d929adc9e8
PopupMenu: Change argument type to optional
Negative wantedY arguments are valid, so we need to be able to
differentiate between an unspecified argument and a
specified-but-negative argument.
2025-09-01 23:33:43 +01:00
reuk
78a93157de
PopupMenu: Remove unused function argument 2025-09-01 23:33:43 +01:00
reuk
edfa87801c
PopupMenu: Extract implementation of ensureItemComponentIsVisible into static function
This makes it a bit easier to see exactly which PopupMenu state is used
during the calculation, and enforces that no menu state is modified
during the call.
2025-09-01 23:33:43 +01:00
reuk
90abc8c1c5
PopupMenu: Clarify behaviour of withItemThatMustBeVisible() in docs 2025-09-01 23:33:42 +01:00
reuk
d2cb90cded
PopupMenu: Simplify expressions in ensureItemComponentIsVisible() 2025-09-01 23:33:42 +01:00
reuk
41a6ed37e4
PopupMenu: Use early return in ensureItemComponentIsVisible() 2025-09-01 23:33:42 +01:00
reuk
9b226f93f4
PopupMenu: Replace raw loop with find_if 2025-09-01 23:33:42 +01:00
attila
79ded8c1f3 PopupMenu: Fix accessibility issue where ticked items couldn't be pressed
The issue became manifest in c51b331318.
In our implementation the toggle action takes precedence over the press
action, making the latter unreachable when the Item is in a checkable
state. Calling isTicked (true) turns the Item into a checkable object.
The onToggle implementation however didn't interact with the isTicked
state, and it didn't fire the press action either. This made the item
non-interactable with screen readers once it got into a ticked state.
2025-07-25 20:42:41 +02:00
Anthony Nicholls
36d07a6ce3 Docs: Replace doxygen preprocessor conditionals with @cond and @endconds 2025-07-21 18:11:43 +02:00
attila
c7390a400f PopupMenu: Make header item components disabled, making them non-interactive using screen readers
This makes screen readers report header items as "dimmed" and offering
no action, similarly to native MacOS menu header items.
2025-07-10 13:51:12 +02:00
reuk
ac2c863ffa
PopupMenu: Add mouse movement timeout back in
This reimplements similar functionality to that removed in
d39789b021.

Unlike the previous implementation, this version will still wait for the
mouse to move over the menu before the countdown timer is allowed to
start. This should avoid the situation where menu items are accidentally
triggered on mouse-up, after a menu opens under the pointer in response
to a mouse-down.
2025-07-03 16:15:03 +01:00
reuk
6091dc8807
PopupMenu: Refactor highlightItemUnderMouse() to reduce nesting 2025-07-03 16:15:03 +01:00
reuk
5d7208bb54
ModifierKeys: Avoid direct access to currentModifiers when reading but not writing 2025-06-19 14:42:49 +01:00
reuk
d77b34f432
PopupMenu: Add notes for testing scenarios 2025-03-05 21:27:51 +00:00
reuk
d39789b021
PopupMenu: Remove timeout before highlighting item under mouse
We now require a mouse movement before highlighting menu items. This is
intended to ensure that the user has intentionally highlighted the menu
item that they wish to trigger.
2025-03-05 21:27:51 +00:00
reuk
51b0319342
PopupMenu: Always attach a global mouse listener
This makes behaviour more consistent between the parented and
non-parented display modes.

Before this change, parented popup menus wouldn't respond to mouse
clicks until the mouse was released once, which meant that clicking and
dragging the mouse over a menu wouldn't trigger a menu item on mouse-up.
2025-03-05 21:27:50 +00:00
reuk
b0d7bad5ee
PopupMenu: Refactor Timer usage in MouseSourceState implementation 2025-03-05 21:27:50 +00:00
Oliver James
98e21c6ad8 PopupMenu: Move section header size calculation into LookAndFeel methods.
This fixes a bug introduced in the previous commit that caused all menu items to be sized too large.
2024-12-19 21:51:40 +00:00
Oliver James
e360d83057 PopupMenu: Move IdealSize modifiers to LookAndFeel 2024-12-19 14:00:23 +00:00
reuk
8ccea668e4
PopupMenu: Adjust mouse interactions so that menu is only dismissed on mouseUp if the mouse has moved
Previously, MouseSourceState::checkButtonState would trigger a menu item
if the MouseSourceState had observed the mouse button transition from
pressed to released while over an item, after more than 250ms had
elapsed since creating the menu window. In situations where the main
thread was very busy, this timeout could sometimes be reached inside the
same mouse click/release gesture. If the menu was created inside a
mouse-down, then simply tapping the mouse could sometimes trigger an
item from the menu as soon as the menu window appeared.

To help avoid accidentally triggering menu items, the menu window now
prevents any item from being triggered by the mouse until either the
mouse has been released once, or the mouse has moved. Put another way,
if the mouse is initially pressed when the menu is shown, it cannot
trigger a menu item unless the mouse is moved before it is released.
2024-10-20 22:59:40 +01:00
reuk
db4a2c0b9f
PopupMenu: Make dismissOnMouseUp private 2024-10-20 22:59:40 +01:00
reuk
570b86ff0c
PopupMenu: Refactor mouseOver detection
The mouseWasOver member will now be updated on each mouse event, rather
than on a timer.
2024-10-20 22:59:40 +01:00
Tom Poole
94d98a2b10 Update licensing information 2024-04-16 11:39:35 +01:00
reuk
903c77b977
PopupMenu: Add accessor for top-level target component to Options class
This allows the LookAndFeel of submenus to query the target component
used for the top-level menu. getTargetComponent() isn't suitable for
this because the target component is set to null for submenus, and this
behaviour can't be changed without potentially breaking code that relies
on the current behaviour.
2023-11-29 13:50:39 +00:00
reuk
7626f86607
PopupMenu: Only display inside safe user area 2023-10-23 16:33:18 +01:00
Tom Poole
6bf9bb9a2e Add final specifiers in implementation files 2023-10-10 16:12:38 +01:00
reuk
081b1ff216
PopupMenu: Avoid dismissing menu in response to mouse events over the menu
In cases where no JUCE component had keyboard focus, clicking a menu
item would cause the menu to be dismissed instead of triggering the
item's action.
2023-04-04 19:55:11 +01:00
Anthony Nicholls
cff722a4af GUI Basics: Refactor juce_gui_basics file structure
- Created a new detail namespace
- Moved shared module implementation details into the detail namespace
- Split dependencies so source files only rely on details in the detail namespace
- Removed all code from the juce_gui_basics.cpp file
2023-03-16 08:53:12 +00:00
reuk
9cfbccca8e
Accessibility: Make createAccessibilityHandler public to allow calls from derived classes 2023-02-09 17:54:18 +00:00
attila
a662e5584b PopupMenu: Add explicit focus order to menu items
Without this VoiceOver will iterate over menu items left to right first,
and iteration order will be affected by whether the PopupMenu gets
broken up into multiple columns due to not enough screen space.
2023-02-03 16:11:11 +01:00
reuk
cf297c75c6
PopupMenu: Fix issue where PopupMenu would sometimes use the default rather than the parent look and feel
Previously, for the following snippet, the menu's LnF was incorrectly
being forced to the default LnF. The correct behaviour is to display the
menu using LnF v4. The menu doesn't have an explicit LnF set, so it
should use the LnF of its parent component.

    LookAndFeel::setDefaultLookAndFeel (&lookAndFeel_V1);
    setLookAndFeel (&lookAndFeel_V4);
    PopupMenu().showMenuAsync (PopupMenu::Options{}.withParentComponent (this));
2023-01-25 17:07:23 +00:00
reuk
e5fc50908e
PopupMenu: Use correct LookAndFeel when computing parent component 2022-12-01 11:41:52 +00:00
reuk
28f2157912
Convert ignoreUnused to [[maybe_unused]] 2022-12-01 11:41:50 +00:00
reuk
8b8ae10059
Build: Replace JUCE_NODISCARD with [[nodiscard]] 2022-09-12 16:14:57 +01:00
attila
c05ec5f9d0 MenuBarComponent: Fix incorrect deactivation of the menu bar
Prior to this commit it was possible to get the menu bar deactivated
by moving the mouse to an adjacent menu item and then back again. If
the movement was quick enough the corresponding PopupMenu would be
dismissed and created again before the dismissal's async command
handler would run. The command handler would see that the dismissed
menu's index and the currently activated index are equal and
deactivate the menu bar.
2022-08-02 14:58:31 +00:00
reuk
2b1745272e
Android: Fix a couple of accessibility-related crashes
These crashes could be seen in the DemoRunner when selecting items in
nested PopupMenu windows.
2022-06-13 15:29:56 +01:00
Tom Poole
2ec861d99e Update licensing banners to JUCE 7 2022-05-16 17:55:48 +01:00
reuk
319da1608d PopupMenu: Avoid potential crash when accessing exitingModalState member 2022-05-05 21:35:49 +01:00
reuk
4bfcb78809
PopupMenu: Use DPI awareness of target component when creating new windows
Also updates the drop shadower so that the DPI-awareness of the shadows
matches the DPI-awareness of the shadowed component.
2022-04-22 14:18:50 +01:00
Tom Poole
dea3fe60e4 Update copyright banners 2022-04-04 12:36:32 +01:00
reuk
c51b331318
PopupMenu Accessibility: Report menu-item ticked state on Windows 2022-03-07 11:03:55 +00:00
attila
a1a8e1339f PopupMenu: Fix click-through from submenu
Previously it was possible to inadvertently activate a menu item by
clicking on a submenu item that was drawn on top of the parent menu.

The root cause was that hide() initiates an asynchronous mechanism
through exitModalState() that eventually destroys the MenuWindow, but
the MouseSourceState timer callbacks and event handlers sometimes still
had a chance to do a state update. Since the submenus have just been
destroyed the update could mistakenly conclude to activate one of the
items of the now lone parent.
2022-02-08 17:38:32 +01:00
reuk
b80927fc91
Nodiscard: Add to builder-pattern functions 2022-01-27 18:43:21 +00:00
reuk
77c24ae49f
PopupMenu: Expose item ticked state to screen readers 2022-01-10 22:15:20 +00:00
reuk
3084a23547
PopupMenu: Improve accessibility of custom components in menus
The 'wrapper' accessibility handler is now ignored if a menu item has a
custom component, and has no submenu, and cannot be triggered
automatically. This avoids the case where a custom menu item may end up
with a wrapper accessibility handler that has no useful actions.

This patch also adds a 'label' argument to the addCustomItem functions,
which allows text for the screen reader to be supplied in the case where
a custom component is in use, but the menu item has accessibility
actions.
2022-01-10 22:15:20 +00:00
Tom Poole
48a7274b08 PopupMenu: Update the example docs 2022-01-10 15:32:13 +00:00
reuk
ffee9b19de
MenuBarComponent: Avoid dereferencing dangling pointer when dismissing menus 2021-11-19 16:35:22 +00:00