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

Should StatusBar always win and capture any defined hotkeys? #1259

Closed
tig opened this issue Apr 27, 2021 · 2 comments
Closed

Should StatusBar always win and capture any defined hotkeys? #1259

tig opened this issue Apr 27, 2021 · 2 comments
Labels
design Issues regarding Terminal.Gui design (bugs, guidelines, debates, etc...)

Comments

@tig
Copy link
Collaborator

tig commented Apr 27, 2021

See #1256.

Proposed fix to TopLevel.cs:

public override bool ProcessKey (KeyEvent keyEvent)
		{
			if (StatusBar != null && StatusBar.ProcessHotKey (keyEvent)
				|| SuperView != null && ((Toplevel)SuperView).StatusBar != null
				&& ((Toplevel)SuperView).StatusBar.ProcessHotKey (keyEvent)) {
				return true;
			}

By doing this `StatusBar` will prevent any other `View` from receiving `ProcessKey` notifications for ANY hotkey defined for the StatusBar. For example:

```c#
			var statusBar = new StatusBar (new StatusItem [] {
				new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()),
				new StatusItem(Key.Enter, "~ENTER~ Message", () => MessageBox.Query ("Message", $"ENTER")),
                                new StatusItem(Key.Enter, "~a~ Message", () => MessageBox.Query ("Message", $"a")),
			});

With this nothing else in the app will ever see 'ENTER' or 'a' keypresses.

My opinion is that this is probably fine. But I haven't considered all of the implications.

@tig tig added the design Issues regarding Terminal.Gui design (bugs, guidelines, debates, etc...) label Apr 27, 2021
@tig tig changed the title Should StatuBar always win and capture any defined hotkeys? Should StatusBar always win and capture any defined hotkeys? Apr 27, 2021
@BDisp
Copy link
Collaborator

BDisp commented Jul 20, 2021

In my opinion if the current focused view has a ProcessHotKey defined, then it must run first.
The order of the Application.ProcessKeyEvent is the following:
ProcessHotKey
ProcessKey
ProcessColdKey

So, due to this I think this not make sense, since the ProcessHotKey runs first than ProcessKey event.

@tig
Copy link
Collaborator Author

tig commented Dec 12, 2023

Closing as a dupe of #3042

@tig tig closed this as completed Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Issues regarding Terminal.Gui design (bugs, guidelines, debates, etc...)
Projects
None yet
Development

No branches or pull requests

2 participants