question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OutConsoleGridView no longer works - ENTER does not work

See original GitHub issue

Recent changes to keyboard handling has broken ocgv.

https://github.com/PowerShell/GraphicalTools/blob/master/docs/Microsoft.PowerShell.ConsoleGuiTools/Out-ConsoleGridView.md

It implements StatusBar like this:

private void AddStatusBar()
        {
            var statusBar = new StatusBar(
                    _applicationData.OutputMode != OutputModeOption.None
                    ? new StatusItem[]
                    {
                        // Use Key.Unknown for SPACE with no delegate because ListView already
                        // handles SPACE
                        new StatusItem(Key.Unknown, "~SPACE~ Mark Item", null),
                        new StatusItem(Key.Enter, "~ENTER~ Accept", () =>
                        {
                            if (Application.Top.MostFocused == _listView)
                            {
                                // If nothing was explicitly marked, we return the item that was selected
                                // when ENTER is pressed in Single mode. If something was previously selected
                                // (using SPACE) then honor that as the single item to return
                                if (_applicationData.OutputMode == OutputModeOption.Single &&
                                    _itemSource.GridViewRowList.Find(i => i.IsMarked) == null)
                                {
                                    _listView.MarkUnmarkRow();
                                }
                                Accept();
                            }
                            else if (Application.Top.MostFocused == _filterField)
                            {
                                _listView.SetFocus();
                            }
                        }),
                        new StatusItem(Key.Esc, "~ESC~ Close", () => Close())
                    }
                    : new StatusItem[]
                    {
                        new StatusItem(Key.Esc, "~ESC~ Close",  () => Close())
                    }
            );

            Application.Top.Add(statusBar);
        }

With recent changes to Terminal.Gui something in how ProcessKey works broke this. The ENTER handler never gets called.

In my opinion, if an app uses StatusBar and defines a hotkey for the StatusBar, that should override all other controls; they should never get that key. This is how it used to work.

I did a test by modifying the ComputedLayout scenario:

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

By doing this, I would expect StatusBar to always win and ENTER would go to StatusBar first. But, that’s not what happens.

This is a breaking behavior change that I believe is a ship-stopper for V1.0.

@BDisp - please help me figure out what changed and a fix. Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11

github_iconTop GitHub Comments

1reaction
tigcommented, Apr 27, 2021

Fixed.

1reaction
tigcommented, Apr 27, 2021

My fix above is a fix (and should probably be incorporated regardless because it is more correct).

I’m curious to see what your proposed fix is!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ENTER does not work · Issue #1256 · gui-cs/Terminal.Gui
Recent changes to keyboard handling has broken ocgv. ... OutConsoleGridView no longer works - ENTER does not work #1256.
Read more >
A new kind of GridView right in your console
ConsoleGuiTools show up in the same console you're prompt is in, support for environments that don't supply a GUI but have a terminal...
Read more >
Terminal.Gui 1.6.3
Terminal drivers for Curses, Windows Console, and the .NET Console mean apps will work well on both color and monochrome terminals. Keyboard and ......
Read more >
How to Fix Enter Key Not Working [4 Quick Solutions]
Enter key stops working for no reason? It can be caused by an outdated driver or keyboard settings. Try these fixes to make...
Read more >
The main enter key stopped working but the numpad one ...
I've tried connecting the keyboard without the dongle. I'm running out of ideas anyone knows how to fix this? keyboard · kubuntu ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found