Skip to content

Fixes #4050 - Select->Activate #4126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 115 commits into
base: v2_develop
Choose a base branch
from
Draft

Conversation

tig
Copy link
Collaborator

@tig tig commented Jun 4, 2025

Fixes

Proposed Changes/Todos

  • Command.Select->Activate
  • Rename Selecting event to Activating, OnSelecting to OnActivating, and RaiseSelecting to RaiseActivating in the View class and all derived classes (e.g., Menuv2, MenuItemv2, CheckBox, FlagSelector).
  • Update related code:
    • Modify SetupCommands in View to use Command.Activate.
    • Update Shortcut.DispatchCommand and other command handlers to reference Activating.
    • Ensure all event handlers and documentation reflect the new terminology.
  • Update Documentation
    • Clarify Activating vs. Accepting:
    • Update view-specific docs
  • Refactor OptionSelector & FlagSelector -> less duplicated code.
  • Revisit how Activate and Accept propogate - esp w/in Shortcut etc...
  • Go through built-in Views and ensure Selected / Activated terminology is correct (e.g. TreeView, TableView, ...)

For another PR

I was going to do this here, but I'll do it in another PR:

  • Introduce Targeted Propagation Model with PropagateActivating
    • Document propagation: Explain the targeted model with PropagateActivating, providing examples for MenuBarv2 and potential Toplevel use cases.
  • Delete RadioGroup - OptionSelector is now a 100% compatible clone

@tig tig requested review from Copilot, BDisp and tznind June 4, 2025 21:07
Copilot

This comment was marked as outdated.

@tig tig requested a review from Copilot June 4, 2025 21:21
Copilot

This comment was marked as outdated.

@tig
Copy link
Collaborator Author

tig commented Jun 4, 2025

I'm not convinced we don't still need a Command.Select in ADDITION to Command.Accept.

Code like this in TableView...

        // BUGBUG: OnCellActivated is misnamed, it should be OnCellAccepted? Or is it OnCellSelected?
        // BUGBUG: Does this mean we still need Command.Select?
        AddCommand (Command.Accept, () => OnCellActivated (new (Table, SelectedColumn, SelectedRow)));

And TreeView:

    /// <summary>
    ///     <para>Triggers the <see cref="ObjectActivated"/> event with the <see cref="SelectedObject"/>.</para>
    ///     <para>This method also ensures that the selected object is visible.</para>
    /// </summary>
    /// <returns><see langword="true"/> if <see cref="ObjectActivated"/> was fired.</returns>
    public bool? ActivateSelectedObjectIfAny (ICommandContext commandContext)
    {
        // By default, Command.Accept calls OnAccept, so we need to call it here to ensure that the event is fired.
        if (RaiseAccepting (commandContext) == true)
        {
            return true;
        }

        T o = SelectedObject;

        if (o is { })
        {
            // TODO: Should this be cancelable?
            ObjectActivatedEventArgs<T> e = new (this, o);
            OnObjectActivated (e);

            return true;
        }

        return false;
    }

???

@BDisp
Copy link
Collaborator

BDisp commented Jun 4, 2025

I think it make sense to have both. Command.Select doesn't mean it was accepted. So, adding Command.Accept will mean it was confirmed and will perform some action, like closing or opening a view, etc.... Command.Select also may perform some action but not definitely. Both must raise the respective events.

tig added 5 commits June 4, 2025 17:04
Updated `PopoverBaseImpl.cs` to clarify mouse event handling in popovers.

Modified `View.Layout.cs` to adjust view count checks for active popovers. Corrected documentation in `ViewportSettingsFlags.cs` regarding the `TransparentMouse` flag.

Added a new test method in `ApplicationPopoverTests.cs` to validate view retrieval under mouse coordinates when a popover is active, with multiple test cases included.

See: gui-cs#4122
- Updated `MouseBinding` struct to include a new constructor for `MouseEventArgs`.
- Enhanced documentation in `View.Mouse.cs` to clarify low-level API methods.
- Refined command handling in `CheckBox` to improve state management.
- Renamed method in `Label` for better clarity in hotkey handling.
- Updated `command.md` to reflect changes in the `Command` system.
- Restructured `mouse.md` for clearer understanding of mouse APIs and best practices.
Working through FlagSelector as an example.
@BDisp
Copy link
Collaborator

BDisp commented Jun 28, 2025

@tig can a MenuBarv2 having a MenuItemv2 with an Action or is mandatory only using MenuBarItemv2?

Edit:
Or maybe more appropriate, can a MenuBarv2 having a MenuBarItemv2 with an Action?

@tig
Copy link
Collaborator Author

tig commented Jun 28, 2025

IIRC my intent was both
What you describe should work. But I doubt I ever tested MenuBarv2 containing a MenuItemv2.

The end user scenario is a MenuBar item that acts just like a StatusBar item.

@BDisp
Copy link
Collaborator

BDisp commented Jun 28, 2025

Works like a charm. Doesn't make sense to set Action in a MenuBarItemv2 because it will handle popover menus, although it's possible but the Action will be ignored. With MenuItemv2 works perfectly. Thanks.

@BDisp
Copy link
Collaborator

BDisp commented Jun 29, 2025

@BDisp I moved your comment to the Issue where it belongs: #4170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants