Skip to content
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

MenuBar positions wrong in some situations #2558

Closed
tznind opened this issue Apr 16, 2023 · 1 comment
Closed

MenuBar positions wrong in some situations #2558

tznind opened this issue Apr 16, 2023 · 1 comment
Labels
v2 For discussions, issues, etc... relavant for v2

Comments

@tznind
Copy link
Collaborator

tznind commented Apr 16, 2023

Describe the bug

Running FileDialog with the following code results in a MenuBar that is mis positioned and has trailing corruption on right. I think it is to do with running using Application.Run directly without having a Top yet? The issue does not manifest in the FileDialogExamples scenario.

Application.Init ();
var dlg = new SaveDialog ("Save my file",
new List<IAllowedType> { new AllowedType("Comma Separated File",".csv") });

Application.Run (dlg);

if (!dlg.Canceled) {
    MessageBox.Query ("File Chosen", $"You chose {dlg.Path}", "Ok");
}

Application.Shutdown ();

image
Opening the MenuBar when running with the above code

Notice how the issue does not manifest in Scenario:

image
Opening the MenuBar when running in Scenario

@tznind tznind added the v2 For discussions, issues, etc... relavant for v2 label Apr 16, 2023
@BDisp
Copy link
Collaborator

BDisp commented Apr 17, 2023

@tig I thing you should avoiding use capital letters variables for parameters, like as this:

public static RunState Begin (Toplevel Toplevel)

In this case if you have a property Toplevel Toplevel {get;} and want to set by Toplevel = Toplevel you will get an ambiguous contradiction. The compiler stay confusing if you are sets the Toplevel property or the Toplevel parameter.

The main problem of this is the Application.Top is the SaveDialog instead of the Top that is set by the Application.Init. The Begin method should set the Application.Current for the SaveDialog. Since both frame are different the menu is positioned based on the SaveDialog instead of the Driver.Cols and Driver.Rows. But isn't enough only setting to the driver bounds. It's needed a view, which is Application.Top to the positioning work.

BDisp added a commit to BDisp/Terminal.Gui that referenced this issue Apr 17, 2023
BDisp added a commit to BDisp/Terminal.Gui that referenced this issue Apr 20, 2023
tig added a commit that referenced this issue May 5, 2023
* Fixes #2558. MenuBar positions wrong in some situations.

* Replacing Application.Top with Application.Current.

* Fix typo.

* Fix shortcut tag overlapping help on smaller width and add more unit test.

* Resizing the console will close all opened menus.

* Resize first the console before show ContextMenu.

* Remove DriverFrame and DriverFrameOffset as not relevant.

* Replace _frame with Frame as requested.

* Fix xml document comment.

* Compare equality between Dialog and Application.Top.

* Move GetDriverLocationOffset and GetDriverLocationOffsetFromCurrent to the Menu.cs.

* Fix merge errors.

* Ensure menu is closed on click.

* Force Height always be 1 to avoid mouse events respond even outside bounds.

* Recovering UseSubMenusSingleFrame hope doesn't break again.

* Fix bugs and made requested changes.

---------

Co-authored-by: Tig <[email protected]>
@tig tig closed this as completed May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 For discussions, issues, etc... relavant for v2
Projects
None yet
Development

No branches or pull requests

3 participants