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

[BUG] Cannot type the letter 'n' in the script editor #177

Closed
brndd opened this issue Oct 9, 2021 · 8 comments
Closed

[BUG] Cannot type the letter 'n' in the script editor #177

brndd opened this issue Oct 9, 2021 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@brndd
Copy link

brndd commented Oct 9, 2021

When using ClassicUO 0.1.9 and Razor 1.7.0.12 (though this also happened with some 1.6 version) on Linux, I am unable to type the letter n in the script editor. Typing it works fine in the pop-out editor. Copy-pasting it in works too.

Steps to reproduce:

  1. Go to the Scripts tab
  2. Create a new script
  3. Try to type the letter n, lower- or uppercase, in the script editor.
@brndd brndd added the bug Something isn't working label Oct 9, 2021
@brndd
Copy link
Author

brndd commented Oct 9, 2021

PS: No, there is nothing wrong with my keyboard ;)

@mfarley281
Copy link

I've had this issue all year.. thought it was just me :) ... Linux + Razor

@markdwags markdwags added the help wanted Extra attention is needed label Nov 29, 2021
@markdwags
Copy link
Owner

Key mapping issue, would need someone to debug it locally to find out what the actual mapping is.

@dallenwilson
Copy link
Contributor

Is happening for me as well, I'll try to figure out where the problem is.

@dallenwilson
Copy link
Contributor

Well, it's not a mapping issue. It's an unlucky combination of some strange form/control behaviour under mono, and a strange design decision by the author of FastColoredTextBox.

The strange decision: FCTB overrides the underlying WinForms events for OnKeyDown, OnKeyUp, and ProcessMnemonic, but rolls it's own OnKeyPressed and OnKeyPressing. The latter two are purely internal and not inherited from it's base class. The 'N' key comes through for OnKeyDown and OnKeyUp, but not ProcessMnemonic. All actual text input processing for the FCTB control is handled in ProcessMnemonic, and since 'N' isn't being passed to it from the base control, 'N' can't be typed in to the script editor.

That seems strange to me, I'd have overridden OnKeyPress and done the heavy lifting there. Anyway, the 'N' does not come through on that one, because...

The strange behaviour under mono: For reasons I haven't yet figured out, when running under Mono the FCTB control is inheriting the Mnemonics of it's parent, MainForm. The only Mnemonic present in MainForm (set not in Razor.Designer.cs, but by the various language translation files under etc/Language/Razor_lang.*) is the New Profile button under the General tab. But, the N key only triggers that button if the General tab has focus; If the Scripts tab has focus, the button traps the key without being activated, and FCTB doesn't get it's N.

I see three options for fixing this: Finding and stopping the incorrect mnemonic-inheritance between MainForm and FCTB, removing the mnemonic entirely, or editing FCTB to move it's input processing out of that function and in to OnKeyDown, OnKeyUp, or adding a proper override for OnKeyPress and doing it there.

@dallenwilson
Copy link
Contributor

Mostly it's strange behaviour under mono. The letter isn't passed to a properly overridden OnKeyPress either.

Three options: Figure out why it happens under Mono and get it fixed, remove mnemonics, or move FCTB's input processing to OnKeyDown or OnKeyUp.

Option one, I don't have the know-how to pursue, and nothing the size of Mono responds quickly to patches anyway. Option two isn't really fixing the problem, and option three would be very annoying, since OnKeyDown/OnKeyUp receive a KeyCode not a KeyChar, meaning we'd have to re-invent the wheel to get upper/lower case and proper modifier handling.

So I went with option four: Ugly hack. PR for it will be in shortly.

@mfarley281
Copy link

Thank you!!!

@dallenwilson
Copy link
Contributor

You are welcome.

I expect that the problem will actually resolve itself if/when the switch away from a Winforms UI happens, without needing a patch for anything.

Until then, and as a purely local work-around, you can edit the file Razor/Language/Razor_lang.enu (That's the english file of course, substitute whatever language you're using), and change the line MainForm::newProfile=&New... to read MainForm::newProfile=New...

Remove the ampersand will disable the mnemonic entirely, and the 'n' key will work again in the script editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants