Example #1
0
 /**
  * @param node The node generating the event.
  * @param x For images only, x coordinate of mouse click.
  * @param y For images only, y coordinate of mouse click.
  * @return True to propagate further, false if consumed.
  */
 public boolean onPressed(ModelNode node, int x, int y) {
   if (node instanceof HTMLAbstractUIElement) {
     HTMLAbstractUIElement uiElement = (HTMLAbstractUIElement) node;
     Function f = uiElement.getOnclick();
     if (f != null) {
       if (!Executor.executeFunction(uiElement, f)) {
         return false;
       }
     }
   }
   if (node instanceof HTMLInputElementImpl) {
     HTMLInputElementImpl hie = (HTMLInputElementImpl) node;
     if (hie.isSubmitInput()) {
       hie.submitForm(new FormInput[] {new FormInput(hie.getName(), hie.getValue())});
     } else if (hie.isImageInput()) {
       String name = hie.getName();
       String prefix = name == null ? "" : name + ".";
       FormInput[] extraFormInputs =
           new FormInput[] {
             new FormInput(prefix + "x", String.valueOf(x)),
             new FormInput(prefix + "y", String.valueOf(y))
           };
       hie.submitForm(extraFormInputs);
     } else if (hie.isResetInput()) {
       hie.resetForm();
     }
   }
   // No propagate
   return false;
 }
Example #2
0
 /** @return True to propagate further and false if the event was consumed. */
 public boolean onMouseClick(ModelNode node) {
   if (logger.isLoggable(Level.INFO)) {
     logger.info("onMouseClick(): node=" + node + ",class=" + node.getClass().getName());
   }
   if (node instanceof HTMLAbstractUIElement) {
     HTMLAbstractUIElement uiElement = (HTMLAbstractUIElement) node;
     Function f = uiElement.getOnclick();
     if (f != null) {
       if (!Executor.executeFunction(uiElement, f)) {
         return false;
       }
     }
   }
   if (node instanceof HTMLLinkElementImpl) {
     ((HTMLLinkElementImpl) node).navigate();
     return false;
   } else if (node instanceof HTMLButtonElementImpl) {
     HTMLButtonElementImpl button = (HTMLButtonElementImpl) node;
     String rawType = button.getAttribute("type");
     String type;
     if (rawType == null) {
       type = "submit";
     } else {
       type = rawType.trim().toLowerCase();
     }
     if ("submit".equals(type)) {
       FormInput[] formInputs =
           new FormInput[] {new FormInput(button.getName(), button.getValue())};
       button.submitForm(formInputs);
     } else if ("reset".equals(type)) {
       button.resetForm();
     } else {
       // NOP for "button"!
     }
     return false;
   }
   ModelNode parent = node.getParentModelNode();
   if (parent == null) {
     return true;
   }
   return this.onMouseClick(parent);
 }