Search in sources :

Example 11 with InputElement

use of org.gwtproject.dom.client.InputElement in project gwtproject by treblereel.

the class EditTextCellTest method testOnBrowserEventEdit.

/**
 * Test switching into edit mode from onBrowserEvent.
 */
public void testOnBrowserEventEdit() {
    NativeEvent event = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
    ViewData expectedViewData = new ViewData("editing");
    Element parent = testOnBrowserEvent("helloWorld", event, "editing", null, null, expectedViewData);
    // Verify the input element.
    Element child = parent.getFirstChildElement();
    assertTrue(InputElement.is(child));
    InputElement input = child.cast();
    assertEquals("editing", input.getValue());
}
Also used : ViewData(org.gwtproject.cell.client.EditTextCell.ViewData) InputElement(org.gwtproject.dom.client.InputElement) Element(org.gwtproject.dom.client.Element) InputElement(org.gwtproject.dom.client.InputElement) NativeEvent(org.gwtproject.dom.client.NativeEvent)

Example 12 with InputElement

use of org.gwtproject.dom.client.InputElement in project gwtproject by treblereel.

the class EditTextCell method updateViewData.

/**
 * Update the view data based on the current value.
 *
 * @param parent the parent element
 * @param viewData the {@link ViewData} object to update
 * @param isEditing true if in edit mode
 * @return the new value
 */
private String updateViewData(Element parent, ViewData viewData, boolean isEditing) {
    InputElement input = (InputElement) parent.getFirstChild();
    String value = input.getValue();
    viewData.setText(value);
    viewData.setEditing(isEditing);
    return value;
}
Also used : InputElement(org.gwtproject.dom.client.InputElement)

Example 13 with InputElement

use of org.gwtproject.dom.client.InputElement in project gwtproject by treblereel.

the class EditTextCell method edit.

/**
 * Convert the cell to edit mode.
 *
 * @param context the {@link Cell.Context} of the cell
 * @param parent the parent element
 * @param value the current value
 */
protected void edit(Cell.Context context, Element parent, String value) {
    setValue(context, parent, value);
    InputElement input = getInputElement(parent);
    input.focus();
    input.select();
}
Also used : InputElement(org.gwtproject.dom.client.InputElement)

Aggregations

InputElement (org.gwtproject.dom.client.InputElement)13 Element (org.gwtproject.dom.client.Element)6 ViewData (org.gwtproject.cell.client.EditTextCell.ViewData)2 HTMLIFrameElement (elemental2.dom.HTMLIFrameElement)1 Context (org.gwtproject.cell.client.Cell.Context)1 NativeEvent (org.gwtproject.dom.client.NativeEvent)1 SubmitEvent (org.gwtproject.user.client.ui.FormPanel.SubmitEvent)1 SubmitHandler (org.gwtproject.user.client.ui.FormPanel.SubmitHandler)1