I have a set of custom controls implemented as standard pair of classes that extend javafx.scene.control.Control and javafx.scene.control.SkinBase. Essentially they are a set of composite controls with a label and one or more "data" controls such as a TextBox for value and ChoiceBox for unit of measure.
I have several properties that interact correctly with SceneBuilder, however two properties, value and min-label-width appear as read only in SceneBuilder. How do I make these properties editable in SceneBuilder? They work correctly when manipulated programmatically when the controls are used in an FXML controller.
I made the min-label-width skinnable with CssMetaData, but that made no difference. I have been looking at the controlsFX source code to get templates on how to do things, but haven't found the answer yet.
// --- min-label-width Defines the space for the label of the control so that
// controls can easily be lined up.
private DoubleProperty minLabelWidth;
public final void setMinLabelWidth(double val)
{
minLabelWidthProperty().set(val);
}
public final Double getMinLabelWidth()
{
return minLabelWidthProperty().get();
}
/**
* lazy allocation of DoubleProperty minLabelWidth.
*
* @return the minLabelWidth
*/
public final DoubleProperty minLabelWidthProperty()
{
if (minLabelWidth == null)
{
minLabelWidth = new StyleableDoubleProperty(100.0)
{
@Override
public Object getBean()
{
return CustomControl.this;
}
@Override
public String getName()
{
return "minLabelWidth"; //$NON-NLS-1$
}
@Override
public CssMetaData<? extends Styleable, Number> getCssMetaData()
{
return StyleableProperties.MIN_LABEL_WIDTH;
}
};
}
return minLabelWidth;
}
private static final CssMetaData<CustomControl, Number> MIN_LABEL_WIDTH =
new CssMetaData<CustomControl, Number>("-min-label-width", SizeConverter.getInstance(), 100)
{
@Override
public Number getInitialValue(CustomControl node)
{
// A vertical Slider should remain vertical
return node.getMinLabelWidth();
}
@Override
public StyleableProperty<Number> getStyleableProperty(CustomControl arg0)
{
return (StyleableProperty<Number>) arg0.minLabelWidthProperty();
}
@Override
public boolean isSettable(CustomControl arg0)
{
return arg0.minLabelWidth == null || !arg0.minLabelWidth.isBound();
}
};
I expect to be able to edit the Min Label Width entry in the custom section of the properties inspector of Java, but the field is grey and read only.