Is there a way to have to placeholder label rendered at the top from the beginning - cosmicmind

Is there a way for the placeholder label of TextField to be rendered at the top from the beginning?
I don't want it to be animated when I focus on the textfield and it's empty.

Yes, if you use version 2.1.0, you can set the TextField's isPlaceholderAnimated property to false. That should give you the desired effect.
For example
let textField = TextField()
textField.isPlaceholderAnimated = false
:)

Related

How does Ext JS set the minimum width of a textfield body?

Say that a textfield is flexed horizontally and no minWidth value has been set. If you resize the textfield to have a small enough width, the body will have its own default minimum width. The following is an example: https://fiddle.sencha.com/#view/editor&fiddle/2hp9
How does Ext JS set the minimum width of the textfield body?
Never mind. I debugged, and I tried textfield.el.dom to show all the elements that composed the textfield. I found out that the element with a data-ref value of 'inputEl' had padding-left and padding-right values. I think that is what makes up the default amount of space of the body.

Switch checkbox text and component

I want to create checkbox with text in the left side and the checkbox component on the right side. How I can switch their place?
CheckBox cb = new CheckBox("Show on Startup");
In JavaFX 8, you can do it like this:
Label lb = new Label("left check");
lb.setGraphic(new CheckBox());
lb.setContentDisplay(ContentDisplay.RIGHT); //You can choose RIGHT,LEFT,TOP,BOTTOM
There might be an easier way, but you can use a label and wrap it with the CheckBox in a HBox:
HBox box = new HBox();
CheckBox cb = new CheckBox();
Label text = new Label("Show on Startup");
box.getChildren().addAll(text, cb);
box.setSpacing(5);
It would be nice if the CheckBox considered the box as its "content" like some of the other controls based on Labeled. Then the contentDisplayProperty could be set to ContentDisplay.RIGHT to achieve this. A nice side-effect would be that we could change the rendering of the box with a setGraphic() call.
As of my release (1.8 EA b129), CheckBox doesn't work that way.

Add text view to dialog

I'm trying to align right text in my dialog.
How can I do that ?
I've tried to:
TextView loadMsg = new TextView(context);
loadMsg.setText("טוען...");
loadMsg.setGravity(Gravity.RIGHT);
dialog.setView(loadMsg);
dialog.show();
But the text does not show.
Sub-way: Create a sub layout and set content view by this
dialog.setContentView(R.layout.dialog_layout);
And design the sub layout the way you like :D
This is because you set the gravity inside the TextView. But if your TextView is laid out with WRAP_CONTENT the gravity really doesn't matter for such a short String. You should insert the TextView inside some Layout, specify FILL_PARENT and setting the layout as the Dialog content view
// width is FILL_PARENT -1, height is WRAP_CONTENT -2
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(-1, -2);
LinerLayout layout = new LinearLayout(context, params);
layout.addView(loadMsg, params);
dialog.setView(layout);
Alternatively, you can set the gravity on the layout itself and set the TextView's width to WRAP_CONTENT
Maybe you are missing LayoutParams in which you have to define heigh and width. If you use wrap_content for width then it would not be aligned as there will no be any extra space.

LWUIT - show TextField blinking Cursor, even if the field is empty

I have a TextField in a Form. This TextField should have focus by default,
which works fine. Now I'd like the user to be aware of that and show him,
that he's inside the TextField - so the TextField cursor should be shown
and blink.
I only found drawTextFieldCursor in DefaultLookAndFeel. but I have
absolutely no idea how to apply this to my TextField.
Any help - and code would be appreciated!
Here's a sample. I still don't have it working.
public void search2() {
searchForm = new Form();
TextField searchArea = new TextField();
searchForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
searchForm.addComponent(searchArea);
searchArea.requestFocus();
int i = Display.getInstance().getKeyCode(Display.GAME_FIRE);
searchArea.keyPressed(i);
searchArea.keyReleased(i);
searchForm.show();
}
What happens is: the TextField is focused, it can be directly edited, the "Abc" mode is shown, but what I really want is to show the user the cursor, so he KNOWS he's inside the TextField. This is not happening... if someone could show me some working code for that...
You want the text field to be in editing mode not for the text field cursor to show (which happens when editing). Use requestFocus() to make sure the text field has focus then use something like:
int i = Display.getInstance().getKeyCode(Display.GAME_FIRE);
tf.keyPressed(i);
tf.keyReleased(i);
The drawTextFieldCursor method has a Graphics parameter , so the way you can draw your cursor is :
derive TextField
in its public void paint(Graphics g) you call drawTextFieldCursor after setting the drawing methods of the TextField's paint Graphic.

Set value for YUI Menu Button

I'm trying to set the assigned value to a YUI Menu Button in order to use values from previous operations.
Something like remembering previous choices.
For label I already know that I can change it with:
button.set("label", "my label")
unfortunatelly I cannot change the value using: button.set("value", "my value")
Any ideia on how can I do this?
Other way would be to force a selection, but I have no ideia on how to do that.
Thanks
just found out that you can use:
var menu = button.getMenu();
var item = menu.getItem(index);
button.set("selectedMenuItem", item);
all that is left for me now is finding the needed index

Resources