Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

How to change behavior of text fields #583

Open
tobiasdiez opened this issue Sep 8, 2019 · 0 comments
Open

How to change behavior of text fields #583

tobiasdiez opened this issue Sep 8, 2019 · 0 comments

Comments

@tobiasdiez
Copy link

tobiasdiez commented Sep 8, 2019

With Java 8, we used a custom TextFieldSkin to add a few custom options to the context menu of a text field. In more recent Java versions, the relevant code now moved to TextInputControlBehavior.

Thus, it would be simple to derive from this behavior class and add additional items to the context menu. However, I don't see a way to replace the original behavior by the customized one, because the behavior is initialized here:

this.behavior = (control instanceof PasswordField)
? new PasswordFieldBehavior((PasswordField)control)
: new TextFieldBehavior(control);
this.behavior.setTextFieldSkin(this);

and behavior in TextFieldSkin is private. Thus, there seems to be no easy way to register a custom behavior class. Did I overlooked something obvious?

tobiasdiez added a commit to JabRef/jabref that referenced this issue Sep 25, 2019
As explained in #5254 (comment) it is no longer possible to customize the context menu items, because the classes related to the text field behavior are not accessible. Thus, instead I simply copied the relevant code from openjdk. Pretty ugly workaround... Fixes #5254 and refs javafxports/openjdk-jfx#583.

Moreover, I removed the custom tab handling because it is now working as expected (i.e. #2902 is fixed in Java 9+).
tobiasdiez added a commit to JabRef/jabref that referenced this issue Sep 26, 2019
As explained in #5254 (comment) it is no longer possible to customize the context menu items, because the classes related to the text field behavior are not accessible. Thus, instead I simply copied the relevant code from openjdk. Pretty ugly workaround... Fixes #5254 and refs javafxports/openjdk-jfx#583.

Moreover, I removed the custom tab handling because it is now working as expected (i.e. #2902 is fixed in Java 9+).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant