dooApp/FXForm2

Disable Edition?

Closed this issue · 6 comments

garzy commented

Hi, I'm working with this FXForm2 and it's awesome for see and edit beans.

However, at this time, I need that the user can't edit anything in the displayed form. My bean only have atributtes of types:

  • String, integer, double, boolean.

What can I do?, I'm trying with FXForm.setDisable(true) but's it's ugly, I would like to see FXForm.setEditable(false) in the next release please.

garzy commented

Finally I've fixed my problem adding this listener to my FXForm:

fxForm.addEventFilter(MouseEvent.ANY, MouseEvent::consume);

But I think this a bit ugly and perhaps it's better to encapsulate inside setEditable method in FXForm.

Thank you for using FXForm2.

If you need a pure read-only form, you can use a ReadOnlyFXForm. For usage, see ReadOnlyForm sample.

If you need something more specific, you can customize the FactoryProvider used for field editors to handle a disable state in your form using myForm.setEditorFactoryProvider(myFactory). Note that you might want to extends/wrap the default factory then.

garzy commented

Thanks for very quickly response. I've tested your solution (I'm missing to see the examples and in wiki there aren't info about my problem or reference to the samples).

Your solution it's ok for other purposes/people, because with readonly property in builder the bean values are presented as PLAIN text (labels...)

I want to see the textfield or checkbox (checkboxs represented now as "true/false" label). IMO it's better appearance with uneditable editors than as an a plain uneditable labels.

Thanks for discover me the usage of FXFormBuilder, I din't know anything about it.

In this case you can use the custom FactoryProvider approach. I have pushed a DisableFactoryProviderWrapper and an EnableDisableForm sample to demonstrate its usage.

garzy commented

OK, you have updated the readme with the samples and you have developed very quickly the requested improvementent.

You're fucking awesome developer!! good work man!! :)

disabled property for node looks good, but for the best result and avoid these "disabled gray appearance" (maybe with css?) should be "editableProperty". But this property only are in editable controls like "TextInputControl"

For now, I continue use my aproach setting eventFilter to consume the event. But your solution with a little css customization it may look good.

Awesome works, thanks!

garzy commented

Hey! I return to your "official solution" because with mine (eventfilter) I can't click on TitledPane bars of my custom FXMLSkin to expand some panels.

For fix the "gray disabled appearance" y wrote this MyBean.css:

.cell,
.form-label,
.form-editor,
.form-title,
.form-tooltip,
.form-constraint {
    -fx-opacity: 1;
}

Would be great if you define this -fx-opacity state as default because IMO looks better than default "disabled gray opacity"

Cheers!