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

V2: TextField numeric input not working on non-Windows platforms #3540

Open
cjlotz opened this issue Jun 14, 2024 · 5 comments
Open

V2: TextField numeric input not working on non-Windows platforms #3540

cjlotz opened this issue Jun 14, 2024 · 5 comments
Assignees
Labels
bug Linux MacOS v2 For discussions, issues, etc... relavant for v2

Comments

@cjlotz
Copy link

cjlotz commented Jun 14, 2024

Hello

For V2, when I'm trying to enter numeric input values for a TextField on non-Windows platforms, the values are not accepted by the control. Is there some specific setting in V2 that I'm missing? Looking at the changes to the TextField between V1 and V2, the V2 OnProcessKeyDown contains an additional check around key codes A-Z which is not in the V1 ProcessKey method - not sure if this is the cause of the issue and why it works on Windows

        // Ignore other control characters.
        if (!a.IsKeyCodeAtoZ && (a.KeyCode < KeyCode.Space || a.KeyCode > KeyCode.CharMask))
        {
            return false;
        }
@tznind
Copy link
Collaborator

tznind commented Jun 14, 2024

This sounds like a bug. But having more information to diagnose would help.

Can you check whether NumLock or Scroll Lock is down when trying to type. Sometimes that makes a difference (although it really shouldn't).

One thing that would help is to know exactly what the keycode is that is being ignored.

You can trap all key events at application level with a global listener (see below) and then look at e in the debugger. If you could provide a screenshot of what that is showing on the affected OS that would be great.

        Application.KeyDown += (s, e) =>
        {
            // Break point here
        };

Another way is to run the 'Keys' scenario in UICatalog on the machines, it logs all key strokes.

image

@cjlotz
Copy link
Author

cjlotz commented Jun 14, 2024

@tznind Thanks for the reply.

Following your suggestion, I added a status bar item that logs the key code. On Windows 11 when I execute this, I see D1, D2... for the digits. On Linux (Ubuntu 22.04 running in WSL on Windows 11), the same key codes are logged as 17, 18, 19...

I wasn't sure if running in WSL might be causing the issue, so I compiled this on my Mac as well. When executing on the Mac I see the same behaviour, i.e. the digits are logged as 17,18,19. On the Mac I have some additional issues with some other key codes as well. For example, Backspace is logged as 95 on Mac, but interpreted correctly on Linux and Windows.

Thoughts?

@cjlotz
Copy link
Author

cjlotz commented Jun 14, 2024

I've now also verified this with the Keys example on the Mac. Running the Keys example for the develop branch works fine, but running the Keys example from the v2_develop branch does not work for digits and some other keys.

BDisp added a commit to BDisp/Terminal.Gui that referenced this issue Jun 15, 2024
@BDisp BDisp self-assigned this Jun 15, 2024
@BDisp BDisp added bug MacOS Linux v2 For discussions, issues, etc... relavant for v2 labels Jun 15, 2024
@BDisp
Copy link
Collaborator

BDisp commented Jun 15, 2024

@cjlotz can you please test the PR #3542, on Linux and macOS to see if it working better. On macOS, for the Alt key to work at all, you need to change the following configuration in Terminal. Thanks.

Terminal > Preferences > Profiles > Keyboard and just check Use Option as Meta key

@cjlotz
Copy link
Author

cjlotz commented Jun 17, 2024

@BDisp I can confirm that the fixes work on my Mac and also in Ubuntu 22.04 running in WSL on Windows 11.

tig added a commit that referenced this issue Jun 17, 2024
Fixes #3540. V2: Keyboard input not working on Unix platforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Linux MacOS v2 For discussions, issues, etc... relavant for v2
Projects
None yet
Development

No branches or pull requests

3 participants