-
Notifications
You must be signed in to change notification settings - Fork 685
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
OutConsoleGridView no longer works - ENTER does not work #1256
Comments
The change that broke this is this one: I think this fix is CORRECT.
public override bool ProcessKey (KeyEvent kb)
{
if (source == null)
return base.ProcessKey (kb);
switch (kb.Key) {
case Key.CursorUp:
case Key.P | Key.CtrlMask:
return MoveUp ();
case Key.CursorDown:
case Key.N | Key.CtrlMask:
return MoveDown ();
case Key.V | Key.CtrlMask:
case Key.PageDown:
return MovePageDown ();
case Key.PageUp:
return MovePageUp ();
case Key.Space:
if (MarkUnmarkRow ())
return true;
else
break;
case Key.Enter:
OnOpenSelectedItem ();
break;
case Key.End:
return MoveEnd ();
case Key.Home:
return MoveHome ();
default:
return false;
}
return true;
} It returns true if the ENTER key was pressed. Which is correct. So, I'm not sure what the right thing to do is. One approach would be for me to change But, I worry that there may be other apps out there that depend on the old behavior. Any suggestions or thoughts? |
@tig it had to be a Edit: |
Proposal: Change Before: public virtual bool OnOpenSelectedItem ()
{
if (source.Count <= selected || selected < 0) return false;
var value = source.ToList () [selected];
OpenSelectedItem?.Invoke (new ListViewItemEventArgs (selected, value));
return true;
} After: public virtual bool OnOpenSelectedItem ()
{
if (source.Count <= selected || selected < 0 || OpenSelectedItem == null) {
return false;
}
var value = source.ToList () [selected];
OpenSelectedItem?.Invoke (new ListViewItemEventArgs (selected, value));
return true;
} Then, have public override bool ProcessKey (KeyEvent kb)
{
...
case Key.Enter:
return OnOpenSelectedItem ();
break;
...
default:
return false;
}
return true;
} |
@tig try this on the 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;
}
if (base.ProcessKey (keyEvent))
return true;
switch (ShortcutHelper.GetModifiersKey (keyEvent)) {
case Key.Q | Key.CtrlMask:
// FIXED: stop current execution of this container
Application.RequestStop ();
break;
case Key.Z | Key.CtrlMask:
Driver.Suspend ();
return true;
|
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! |
Interesting. This fixes the issue too. But I wonder if my original suggestion that StatusBar should always win is actually correct now. What do you think? |
The problem of my fix is that the |
I'm a little split here. Can anyone else be able to pronounce? @tznind, @jmperricone , please. |
How about we take my fix now, since it's lower risk (more surgical)? It fixes the pressing issue of unblocking 1.0. |
@tig sometimes a view that handle some keystroke need to check if it's necessary to do something or not, but need to set it to true because it has the focus and don't want another view take another action for that keystroke. Think well :-) But if it's a fix with a lower risk. |
Fixed. |
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:With recent changes to
Terminal.Gui
something in howProcessKey
works broke this. TheENTER
handler never gets called.In my opinion, if an app uses
StatusBar
and defines a hotkey for theStatusBar
, 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:By doing this, I would expect
StatusBar
to always win andENTER
would go toStatusBar
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.
The text was updated successfully, but these errors were encountered: