use of com.codename1.ui.Button in project CodenameOne by codenameone.
the class HTMLForm method reset.
/**
* Called when a form reset is needed and resets all the form fields to their default values.
*/
void reset() {
for (Enumeration e = defaultValues.keys(); e.hasMoreElements(); ) {
Object input = e.nextElement();
if (input instanceof TextArea) {
// catches both textareas and text input fields
String defVal = (String) defaultValues.get(input);
if (defVal == null) {
defVal = "";
}
((TextArea) input).setText(defVal);
} else if (input instanceof ComboBox) {
OptionItem defVal = (OptionItem) defaultValues.get(input);
ComboBox combo = ((ComboBox) input);
if (defVal != null) {
combo.setSelectedItem(defVal);
} else if (combo.size() > 0) {
combo.setSelectedIndex(0);
}
}
}
for (Enumeration e = defaultCheckedButtons.elements(); e.hasMoreElements(); ) {
Button b = (Button) e.nextElement();
if (!b.isSelected()) {
setButton(b, true);
}
}
for (Enumeration e = defaultUncheckedButtons.elements(); e.hasMoreElements(); ) {
Button b = (Button) e.nextElement();
if (b.isSelected()) {
setButton(b, false);
}
}
}
use of com.codename1.ui.Button in project CodenameOne by codenameone.
the class ComponentSelector method setIcon.
/**
* Sets the icon of all elements in this set to a material icon. This will use
* the foreground color of the label.
* @param materialIcon The material icon charcode.
* @return Self for chaining.
*/
public ComponentSelector setIcon(char materialIcon) {
for (Component c : this) {
if (c instanceof Label) {
Label l = (Label) c;
Style style = new Style();
Style cStyle = c.getUnselectedStyle();
style.setBgTransparency(0);
style.setFgColor(cStyle.getFgColor());
l.setIcon(FontImage.createMaterial(materialIcon, style, 3));
if (c instanceof Button) {
Button b = (Button) c;
style = new Style();
cStyle = c.getPressedStyle();
style.setBgTransparency(0);
style.setFgColor(cStyle.getFgColor());
b.setPressedIcon(FontImage.createMaterial(materialIcon, style, 3));
}
}
}
return this;
}
use of com.codename1.ui.Button in project CodenameOne by codenameone.
the class Button method pointerReleased.
/**
* {@inheritDoc}
*/
public void pointerReleased(int x, int y) {
if (pointerReleasedListeners != null && pointerReleasedListeners.hasListeners()) {
ActionEvent ev = new ActionEvent(this, ActionEvent.Type.PointerReleased, x, y);
pointerReleasedListeners.fireActionEvent(ev);
if (ev.isConsumed()) {
return;
}
}
Form f = getComponentForm();
// might happen when programmatically triggering press
if (f != null) {
if (f.buttonsAwatingRelease != null) {
f.buttonsAwatingRelease.remove(this);
}
}
// button shouldn't fire an event when a pointer is dragged into it
if (state == STATE_PRESSED) {
released(x, y);
}
if (restoreDragPercentage > -1) {
Display.getInstance().setDragStartPercentage(restoreDragPercentage);
}
}
use of com.codename1.ui.Button in project CodenameOne by codenameone.
the class TestUtils method clickButtonByLabel.
/**
* Clicks the button with the given label
* @param text the text on the button
*/
public static void clickButtonByLabel(String text) {
if (verbose) {
log("clickButtonByLabel(" + text + ")");
}
Button b = (Button) findLabelText(text);
waitFor(20);
b.pressed();
waitFor(20);
b.released();
waitFor(20);
}
use of com.codename1.ui.Button in project CodenameOne by codenameone.
the class TestUtils method clickButtonByName.
/**
* Clicks the button with the given label
* @param name the name of the button
*/
public static void clickButtonByName(String name) {
if (verbose) {
log("clickButtonByName(" + name + ")");
}
Button b = (Button) findByName(name);
waitFor(20);
b.pressed();
waitFor(20);
b.released();
waitFor(20);
}
Aggregations