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

Question: disabling new line functionality (pressing return) #763

Closed
SkyAphid opened this issue Jun 30, 2018 · 2 comments
Closed

Question: disabling new line functionality (pressing return) #763

SkyAphid opened this issue Jun 30, 2018 · 2 comments

Comments

@SkyAphid
Copy link
Contributor

SkyAphid commented Jun 30, 2018

I'm using a InclineCssTextArea as a basic field, but the problem is the new line functionality doesn't seem customizable. I know I can just use TextField, but one of the reasons why I chose RichTextFX is because it can handle special characters like heart symbols automatically if the font doesn't have them by default. So I don't have any choice but to use your text areas.

capture

To summarize, how do I prevent being able to press enter and start a new line on a text area like this? It needs to remain in one line forever. I already have setWrapText(false) on the area.

I saw this, but I was wondering if any progress had been made on it, or if you guys can make a workaround. I really need the special character handling of RichTextFX, so there's not an alternative for me unless I remove that functionality, which is very bad because my software is for video games, which tend to need those characters for creative reasons. I'm okay with something like overriding the button listener to disable it, or something equally hacky like that for now until you guys make a proper system for it.

Thanks!

@JordanMartinez
Copy link
Contributor

Check the Override Default Behavior demo that I mentioned in my reply to that issue. Also look at the default behavior for understanding the same pattern there and how to use InputMapTemplate for better memory usage.

Essentially, you're going to override this behavior with something like:

InputMapTemplate.consume(EventPattern.keyPressed(KeyCode.Enter))

Follow the pattern and simply consume the Enter so it does nothing.

Also, please open a new issue requesting a RichTextField feature since, I believe, that should also fall in this project.

@SkyAphid
Copy link
Contributor Author

Thanks, for anyone else who needs this, here's the utility function I ended up making:

public static void disableMultiLineShortcuts(InlineCssTextArea area) {
	InputMap<Event> map = InputMap.consume(anyOf(keyPressed(ENTER, SHORTCUT_ANY, SHIFT_ANY)));
	Nodes.addInputMap(area, map);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants